├── ic_launcher.png ├── ic_launcher-web.png ├── widget_on hires.png ├── ic_launcher_web_new.png ├── res ├── drawable │ ├── ic_launcher.png │ ├── screenoff.png │ ├── widget_off.png │ ├── widget_on.png │ ├── statusbar_off.png │ ├── statusbar_on.png │ └── widget_charging_on.png ├── values │ ├── colors.xml │ ├── dimens.xml │ ├── styles.xml │ └── strings.xml ├── xml │ ├── deviceinfo.xml │ ├── screenoff_appwidget_info.xml │ ├── toggleonoff_appwidget_info.xml │ └── widget_configure.xml ├── values-sw600dp │ └── dimens.xml ├── values-w600dp │ └── styles.xml ├── values-sw720dp-land │ └── dimens.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml ├── layout │ ├── screenoff_appwidget.xml │ ├── activity_main.xml │ ├── toggleonoff_appwidget.xml │ ├── changelogdlg.xml │ ├── layout_notification.xml │ └── activity_settings.xml ├── layout-land │ └── toggleonoff_appwidget.xml ├── menu │ └── menu.xml ├── values-zh-rCN │ └── strings.xml ├── values-nl │ └── strings.xml ├── xml-v14 │ └── widget_configure.xml ├── values-zh │ └── strings.xml ├── values-cs │ └── strings.xml ├── values-vi │ └── strings.xml ├── values-sk │ └── strings.xml ├── values-fr │ └── strings.xml ├── values-de │ └── strings.xml ├── values-uk │ └── strings.xml └── values-ru │ └── strings.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── iPad-2-black-blue-cover-256.psd ├── screenshots └── autoscreenonoff_preferences.png ├── .gitignore ├── .classpath ├── PowerOffTest ├── local.properties ├── PowerOffTest.iml ├── project.properties ├── src │ └── com │ │ └── danielkao │ │ └── autoscreenonoff │ │ └── tests │ │ ├── SensorServiceTest.java │ │ ├── MainActivityTest.java │ │ └── SettingActivityTest.java ├── ant.properties ├── proguard-project.txt ├── AndroidManifest.xml └── build.xml ├── local.properties ├── project.properties ├── .travis.yml ├── proguard-project.txt ├── src └── com │ └── danielkao │ └── autoscreenonoff │ ├── receiver │ ├── TurnOffReceiver.java │ ├── AppReplaceReceiver.java │ ├── BootReceiver.java │ └── ChargingStatusChangeReceiver.java │ ├── strategy │ ├── BaseStrategy.java │ ├── BaseTurnOnStrategy.java │ └── BaseTurnOffStrategy.java │ ├── ui │ ├── MyPreferenceCategory.java │ ├── TimePreference.java │ ├── MainActivity.java │ ├── AppMultiselectListPreference.java │ └── AutoScreenOnOffPreferenceActivity.java │ ├── provider │ ├── ScreenOffAppWidgetProvider.java │ └── ToggleAutoScreenOnOffAppWidgetProvider.java │ └── util │ ├── EnvironmentInfoUtils.java │ └── CV.java ├── .project ├── README.md ├── gradlew.bat ├── PowerOff.iml ├── AndroidManifest.xml └── gradlew /ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /widget_on hires.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/widget_on hires.png -------------------------------------------------------------------------------- /ic_launcher_web_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/ic_launcher_web_new.png -------------------------------------------------------------------------------- /res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable/screenoff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/screenoff.png -------------------------------------------------------------------------------- /res/drawable/widget_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/widget_off.png -------------------------------------------------------------------------------- /res/drawable/widget_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/widget_on.png -------------------------------------------------------------------------------- /res/drawable/statusbar_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/statusbar_off.png -------------------------------------------------------------------------------- /res/drawable/statusbar_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/statusbar_on.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /iPad-2-black-blue-cover-256.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/iPad-2-black-blue-cover-256.psd -------------------------------------------------------------------------------- /res/drawable/widget_charging_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/res/drawable/widget_charging_on.png -------------------------------------------------------------------------------- /screenshots/autoscreenonoff_preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plateaukao/AutoScreenOnOff/HEAD/screenshots/autoscreenonoff_preferences.png -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FBFBFB 4 | #7F000000 5 | #FFFF0000 6 | -------------------------------------------------------------------------------- /res/xml/deviceinfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /res/values-w600dp/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | .idea/ 3 | build/ 4 | .gradle/ 5 | 6 | PowerOffTest/gen/com/danielkao/autoscreenonoff/tests/BuildConfig.java 7 | 8 | PowerOffTest/gen/com/danielkao/autoscreenonoff/tests/Manifest.java 9 | 10 | PowerOffTest/gen/com/danielkao/autoscreenonoff/tests/R.java 11 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/xml/screenoff_appwidget_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /res/xml/toggleonoff_appwidget_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /PowerOffTest/local.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | 7 | # location of the SDK. This is only used by Ant 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=/Applications/Android Studio.app/sdk 11 | -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | #Fri Feb 06 03:06:44 CST 2015 11 | #sdk.dir=/Users/plateau/Downloads/adt-bundle-mac-x86_64-20140702/sdk 12 | -------------------------------------------------------------------------------- /res/layout/screenoff_appwidget.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | -------------------------------------------------------------------------------- /PowerOffTest/PowerOffTest.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /PowerOffTest/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | # Uncomment the lines below if you want to 6 | # use the latest revision of Android SDK Tools 7 | # - platform-tools 8 | # - tools 9 | 10 | # The BuildTools version used by your project 11 | - build-tools-21.1.2 12 | 13 | # The SDK version used to compile your project 14 | - android-20 15 | 16 | # Additional components 17 | #- extra-google-google_play_services 18 | #- extra-google-m2repository 19 | #- extra-android-m2repository 20 | #- addon-google_apis-google-19 21 | 22 | # Specify at least one system image, 23 | # if you need to run emulator(s) during your tests 24 | #- sys-img-armeabi-v7a-android-19 25 | #- sys-img-x86-android-17 26 | -------------------------------------------------------------------------------- /PowerOffTest/src/com/danielkao/autoscreenonoff/tests/SensorServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.tests; 2 | 3 | import android.test.ServiceTestCase; 4 | import com.danielkao.autoscreenonoff.service.SensorMonitorService; 5 | 6 | /** 7 | * Created by plateau on 2013/06/04. 8 | */ 9 | public class SensorServiceTest extends ServiceTestCase{ 10 | SensorMonitorService ss; 11 | public SensorServiceTest(Class serviceClass) { 12 | super(serviceClass); 13 | } 14 | 15 | @Override 16 | protected void setUp() throws Exception { 17 | super.setUp(); 18 | 19 | ss = (SensorMonitorService)getService(); 20 | } 21 | 22 | public void testAutoOn(){ 23 | assertTrue(true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PowerOffTest/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | tested.project.dir=/Users/plateau/Documents/workspace/PowerOff 19 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /PowerOffTest/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /res/layout/toggleonoff_appwidget.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 22 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 23 | 24 | -------------------------------------------------------------------------------- /res/layout/changelogdlg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | 13 | 17 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/receiver/TurnOffReceiver.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.receiver; 2 | 3 | import android.app.admin.DeviceAdminReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | 8 | 9 | public class TurnOffReceiver extends DeviceAdminReceiver { 10 | private static final String TAG = "TurnOffReceiver"; 11 | public CharSequence onDisableRequested(Context paramContext, Intent paramIntent) 12 | { 13 | return "This is an optional message to warn the user about disabling."; 14 | } 15 | 16 | public void onDisabled(Context paramContext, Intent paramIntent) 17 | { 18 | Log.v(TAG,"onDisabled"); 19 | } 20 | 21 | public void onEnabled(Context paramContext, Intent paramIntent) 22 | { 23 | Log.v(TAG,"onEnabled"); 24 | } 25 | 26 | public void onPasswordChanged(Context paramContext, Intent paramIntent) 27 | { 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /PowerOffTest/src/com/danielkao/autoscreenonoff/tests/MainActivityTest.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.tests; 2 | 3 | import android.test.ActivityInstrumentationTestCase2; 4 | import com.danielkao.autoscreenonoff.ui.MainActivity; 5 | 6 | /** 7 | * This is a simple framework for a test of an Application. See 8 | * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on 9 | * how to write and extend Application tests. 10 | *

11 | * To run this test, you can type: 12 | * adb shell am instrument -w \ 13 | * -e class com.danielkao.autoscreenonoff.tests.MainActivityTest \ 14 | * com.danielkao.autoscreenonoff.tests/android.test.InstrumentationTestRunner 15 | */ 16 | public class MainActivityTest extends ActivityInstrumentationTestCase2 { 17 | 18 | public MainActivityTest() { 19 | super("com.danielkao.autoscreenonoff", MainActivity.class); 20 | } 21 | 22 | public void test1(){ 23 | assertTrue(true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /res/layout-land/toggleonoff_appwidget.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 26 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/strategy/BaseStrategy.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.strategy; 2 | 3 | import android.app.admin.DevicePolicyManager; 4 | import android.content.Context; 5 | import android.os.PowerManager; 6 | import android.os.PowerManager.WakeLock; 7 | import android.os.Handler; 8 | 9 | /** 10 | * Created by plateau on 2013/09/12. 11 | */ 12 | public class BaseStrategy { 13 | 14 | protected Handler handler; 15 | 16 | protected WakeLock screenLock; 17 | protected DevicePolicyManager deviceManager; 18 | protected PowerManager mPowerManager; 19 | protected Context context; 20 | 21 | public BaseStrategy(Context context, WakeLock screenLock) { 22 | this.screenLock = screenLock; 23 | this.context = context; 24 | 25 | deviceManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); 26 | mPowerManager = ((PowerManager) context.getSystemService(Context.POWER_SERVICE)); 27 | handler = new Handler(); 28 | } 29 | 30 | public void process(float sensorValue){}; 31 | } 32 | -------------------------------------------------------------------------------- /res/menu/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | 7 | 10 | 13 | 16 | 19 | 22 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/ui/MyPreferenceCategory.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.ui; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.preference.PreferenceCategory; 6 | import android.util.AttributeSet; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Created by plateau on 2013/06/05. 12 | */ 13 | public class MyPreferenceCategory extends PreferenceCategory{ 14 | public MyPreferenceCategory(Context context) { 15 | super(context); 16 | } 17 | 18 | public MyPreferenceCategory(Context context, AttributeSet attrs) { 19 | super(context, attrs); 20 | } 21 | 22 | public MyPreferenceCategory(Context context, AttributeSet attrs, 23 | int defStyle) { 24 | super(context, attrs, defStyle); 25 | } 26 | 27 | @Override 28 | protected void onBindView(View view) { 29 | super.onBindView(view); 30 | TextView titleView = (TextView) view.findViewById(android.R.id.title); 31 | titleView.setTextColor(Color.parseColor("#45A0D9")); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /PowerOffTest/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | 13 | 18 | 22 | 23 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PowerOff 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | 35 | src/com/danielkao/poweroff/ChargingStatusChangeReceiver.java 36 | 1 37 | /Users/plateau/Documents/workspace/PowerOff/src/com/danielkao/autoscreenonoff/ChargingStatusChangeReceiver.java 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PowerOffTest/src/com/danielkao/autoscreenonoff/tests/SettingActivityTest.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.tests; 2 | 3 | import android.preference.SwitchPreference; 4 | import android.test.ActivityInstrumentationTestCase2; 5 | import com.danielkao.autoscreenonoff.ui.AutoScreenOnOffPreferenceActivity; 6 | import com.danielkao.autoscreenonoff.util.CV; 7 | 8 | /** 9 | * Created by plateau on 2013/06/03. 10 | */ 11 | public class SettingActivityTest extends ActivityInstrumentationTestCase2 { 12 | AutoScreenOnOffPreferenceActivity activity; 13 | 14 | public SettingActivityTest(){ 15 | super("com.danielkao.autoscreenonoff", AutoScreenOnOffPreferenceActivity.class); 16 | } 17 | 18 | @Override 19 | protected void setUp() throws Exception { 20 | super.setUp(); 21 | 22 | activity = (AutoScreenOnOffPreferenceActivity)getActivity(); 23 | } // end of setUp() method definition 24 | 25 | public void testSettingActivityExists(){ 26 | assertTrue(activity!=null); 27 | } 28 | public void testPrefState(){ 29 | SwitchPreference spAuto = (SwitchPreference) activity.getPreferenceScreen().findPreference(CV.PREF_AUTO_ON); 30 | SwitchPreference spCharge = (SwitchPreference) activity.getPreferenceScreen().findPreference(CV.PREF_CHARGING_ON); 31 | if(spAuto.isEnabled()) 32 | assertTrue(!spCharge.isEnabled()); 33 | if(spCharge.isEnabled()) 34 | assertTrue(!spAuto.isEnabled()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /res/layout/layout_notification.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 17 | 18 | 28 | 29 | 39 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/receiver/AppReplaceReceiver.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import com.danielkao.autoscreenonoff.util.CV; 7 | 8 | /** 9 | * Created by plateau on 2013/06/10. 10 | */ 11 | public class AppReplaceReceiver extends BroadcastReceiver { 12 | public void onReceive(Context context, Intent intent) { 13 | String pkg = intent.getPackage(); 14 | CV.logv("AppReplaceReceiver app updated:%s", pkg); 15 | // screen onoff is upgraded 16 | if(pkg != null && pkg.equals("com.danielkao.autoscreenonoff")){ 17 | 18 | // auto pref is on 19 | if(CV.getPrefAutoOnoff(context)){ 20 | CV.logv("start service by app receiver receiver"); 21 | // send intent to service 22 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 23 | i.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_TOGGLE); 24 | i.putExtra(CV.SERVICETYPE, CV.SERVICETYPE_SETTING); 25 | context.startService(i); 26 | }// check whether pre charging is on, and is under charging 27 | else if(CV.getPrefChargingOn(context) && CV.isPlugged(context)){ 28 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 29 | i.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_TURNON); 30 | i.putExtra(CV.SERVICETYPE, CV.SERVICETYPE_CHARGING); 31 | context.startService(i); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 14 | 25 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/receiver/BootReceiver.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import com.danielkao.autoscreenonoff.util.CV; 7 | 8 | /** 9 | * Created by plateau on 2013/06/03. 10 | */ 11 | public class BootReceiver extends BroadcastReceiver { 12 | public void onReceive(Context context, Intent intent) { 13 | 14 | CV.logv("boot receiver"); 15 | 16 | // auto pref is on 17 | if(CV.getPrefAutoOnoff(context)){ 18 | CV.logv("start service by boot receiver"); 19 | // send intent to service 20 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 21 | i.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_TOGGLE); 22 | i.putExtra(CV.SERVICETYPE, CV.SERVICETYPE_SETTING); 23 | context.startService(i); 24 | 25 | 26 | // re-invoke alarmManager 27 | if(CV.getPrefSleeping(context)){ 28 | Intent j = new Intent(CV.SERVICE_INTENT_ACTION); 29 | j.putExtra(CV.SERVICEACTION, 30 | CV.SERVICEACTION_SET_SCHEDULE); 31 | context.startService(j); 32 | } 33 | 34 | }// check whether pre charging is on, and is under charging 35 | else if(CV.getPrefChargingOn(context) && CV.isPlugged(context)){ 36 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 37 | i.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_TURNON); 38 | i.putExtra(CV.SERVICETYPE, CV.SERVICETYPE_CHARGING); 39 | context.startService(i); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto Screen OnOff 2 | 3 | [![Get it on Google Play](https://developer.android.com/images/brand/en_generic_rgb_wo_45.png)](https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff) 4 | 5 | ## Overview 6 | *an android app to turn on/off screen automatically by detecting values from proximity sensor.* 7 | 8 | ## Features 9 | 1. By detecting p-sensor, automatically turn on/off the screen for you. 10 | 2. Allows you to only enable the function during charging. 11 | 3. Allows you to disable the feature when the screen is rotated. 12 | 4. Separate timeout values for screen on/off delay to prevent from accidentally triggering the feature. 13 | 5. A widget is supported to quickly toggle the function. 14 | 6. Notification is supported to quickly toggle function, or directly turn screen off. 15 | 16 | ### How it works 17 | Modify Settings in "Auto Screen Settings" app and enable the function 18 | 19 | or 20 | 21 | 1. Add widget "AutoScreenOnOff" to your home screen 22 | 2. Press once on the icon to trigger Device Management Confirmation Dialog. 23 | 3. Agree to activate device management. (This is required to turn off the screen) 24 | 4. Now everything should work now. Try cover your hand over the top area of the screen (where the proximity sensor might be located) to see if it works. 25 | 26 | ## Development 27 | This project is built using Android Studio. If you want to clone the git and modify the codes, please use Android Studio too. 28 | 29 | ## Screenshots 30 | Preference Screen 31 | preference 32 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/receiver/ChargingStatusChangeReceiver.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import com.danielkao.autoscreenonoff.util.CV; 7 | 8 | import static android.content.Intent.ACTION_POWER_CONNECTED; 9 | import static android.content.Intent.ACTION_POWER_DISCONNECTED; 10 | 11 | // TODO: boot receiver 12 | // dialog for new versions: add ad here? 13 | 14 | /** 15 | * Created by plateau on 2013/05/20. 16 | */ 17 | public class ChargingStatusChangeReceiver extends BroadcastReceiver { 18 | public void onReceive(Context context, Intent intent) { 19 | 20 | // not enabled 21 | if(!CV.getPrefChargingOn(context)) 22 | return; 23 | 24 | String action = intent.getAction(); 25 | if(action.equals(ACTION_POWER_CONNECTED)) { 26 | CV.logv("is charging"); 27 | 28 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 29 | i.putExtra(CV.SERVICEACTION, 30 | CV.SERVICEACTION_TURNON); 31 | i.putExtra(CV.SERVICETYPE, 32 | CV.SERVICETYPE_CHARGING); 33 | context.startService(i); 34 | } 35 | else if(action.equals(ACTION_POWER_DISCONNECTED)) { 36 | CV.logv("is not charging anymore"); 37 | 38 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 39 | i.putExtra(CV.SERVICEACTION, 40 | CV.SERVICEACTION_TURNOFF); 41 | i.putExtra(CV.SERVICETYPE, 42 | CV.SERVICETYPE_CHARGING); 43 | context.startService(i); 44 | 45 | } 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/provider/ScreenOffAppWidgetProvider.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.provider; 2 | 3 | import android.app.PendingIntent; 4 | import android.appwidget.AppWidgetManager; 5 | import android.appwidget.AppWidgetProvider; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.widget.RemoteViews; 9 | import com.danielkao.autoscreenonoff.R; 10 | import com.danielkao.autoscreenonoff.util.CV; 11 | 12 | public class ScreenOffAppWidgetProvider extends AppWidgetProvider { 13 | 14 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, 15 | int[] appWidgetIds) { 16 | final int N = appWidgetIds.length; 17 | 18 | // Perform this loop procedure for each App Widget that belongs to this 19 | // provider 20 | for (int i = 0; i < N; i++) { 21 | CV.logv("onUpdate in AppWidget"); 22 | int appWidgetId = appWidgetIds[i]; 23 | updateRemoteViews(context, appWidgetManager, appWidgetId,false); 24 | } 25 | } 26 | 27 | private void updateRemoteViews(Context context, AppWidgetManager awm, int appWidgetId, boolean isCharging){ 28 | CV.logv("onUpdate in AppWidget"); 29 | 30 | Intent intentScreenOff = new Intent(CV.SERVICE_INTENT_ACTION); 31 | intentScreenOff.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_SCREENOFF); 32 | PendingIntent pendingIntent = PendingIntent.getService(context, 0, 33 | intentScreenOff, PendingIntent.FLAG_UPDATE_CURRENT); 34 | 35 | // Get the layout for the App Widget and attach an on-click listener 36 | // to the button 37 | RemoteViews views = new RemoteViews(context.getPackageName(), 38 | R.layout.screenoff_appwidget); 39 | views.setOnClickPendingIntent(R.id.imageview, pendingIntent); 40 | 41 | 42 | // Tell the AppWidgetManager to perform an update on the current app widget 43 | awm.updateAppWidget(appWidgetId, views); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/util/EnvironmentInfoUtils.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.util; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.os.Build; 6 | import android.telephony.TelephonyManager; 7 | import android.content.pm.PackageManager.NameNotFoundException; 8 | 9 | /** 10 | * Created by plateau on 2013/12/02. 11 | */ 12 | public class EnvironmentInfoUtils { 13 | public static String getApplicationInfo(Context context) { 14 | return String.format("%s\n%s\n%s\n%s\n%s\n%s\n", 15 | getCountry(context), getBrandInfo(), getModelInfo(), 16 | getDeviceInfo(), getVersionInfo(context), getLocale(context)); 17 | } 18 | 19 | public static String getCountry(Context context) { 20 | TelephonyManager mTelephonyMgr = (TelephonyManager) context 21 | .getSystemService(Context.TELEPHONY_SERVICE); 22 | return String.format("Country: %s", 23 | mTelephonyMgr.getNetworkCountryIso()); 24 | } 25 | 26 | public static String getModelInfo() { 27 | return String.format("Model: %s", Build.MODEL); 28 | } 29 | 30 | public static String getBrandInfo() { 31 | return String.format("Brand: %s", Build.BRAND); 32 | } 33 | 34 | public static String getDeviceInfo() { 35 | return String.format("Device: %s", Build.DEVICE); 36 | } 37 | 38 | public static String getLocale(Context context) { 39 | return String.format("Locale: %s", context.getResources() 40 | .getConfiguration().locale.getDisplayName()); 41 | } 42 | 43 | public static String getVersionInfo(Context context) { 44 | String version = null; 45 | 46 | try { 47 | PackageInfo info = context.getPackageManager().getPackageInfo( 48 | context.getPackageName(), 0); 49 | version = info.versionName + " (release " + info.versionCode 50 | + ")"; 51 | } catch (NameNotFoundException e) { 52 | version = "not_found"; 53 | } 54 | 55 | return String.format("Version: %s", version); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 自动屏幕开关 5 | 设置 6 | Hello world! 7 | 开启屏幕自动控制 8 | 关闭屏幕自动控制 9 | 需要此权限以关闭屏幕 10 | 自动屏幕开关 11 | 12 | 自动屏幕开关 13 | 插入电源时设置 14 | 自动屏幕开关设置 15 | 16 | 屏幕自动控制设置 17 | 插入电源时的设置 18 | 19 | 当接上 USB 线时,启动本功能;拔出时,则中断。 20 | 仅在接上电源时启动 21 | 22 | 启动后,如果物体(如保护盖)遮盖于感测器上方,则屏幕自动关闭;反之,则自动开启。 23 | 启动 24 | 移除 25 | 26 | 前往谷哥商店 27 | 前往GitHub 28 | 29 | 画面横置时,暂时不关闭画面,因为此时可能在拍照或看影片。 30 | 横屏时暂时停止作用 31 | 32 | 遮盖时,延迟多久才关闭画面。(可避免误触)\n\n目前设定: %s 33 | 关闭画面延迟 34 | 开盖时,延迟多久才开启画面\n\n目前设定: %s 35 | 开启画面延迟 36 | 37 | 与关闭画面延迟相同 38 | 立马生效 39 | 0.5 秒 40 | 1 秒 41 | 2 秒 42 | 3 秒 43 | 10 秒 44 | 45 | 缷载软件 46 | 确定要缷载本软件吗? 47 | Play sound while auto turning off screen 48 | Play Close Sound 49 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/strategy/BaseTurnOnStrategy.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.strategy; 2 | 3 | import android.content.Context; 4 | import android.os.PowerManager.WakeLock; 5 | import com.danielkao.autoscreenonoff.util.CV; 6 | 7 | /** 8 | * Created by plateau on 2013/09/12. 9 | */ 10 | public class BaseTurnOnStrategy extends BaseStrategy{ 11 | 12 | //handle timeout function 13 | private int CALLBACK_EXISTS=1; 14 | //private Timer timer; 15 | 16 | protected Context context; 17 | 18 | public BaseTurnOnStrategy(Context context, WakeLock screenLock) { 19 | super(context,screenLock); 20 | } 21 | 22 | @Override 23 | public void process(float sensorValue) { 24 | // cover 25 | if (sensorValue == 0f) { 26 | // 27 | } 28 | // uncover 29 | else { 30 | if (!mPowerManager.isScreenOn()) { 31 | long timeout = (long) CV.getPrefTimeoutUnlock(context); 32 | if(timeout==0) 33 | turnOn(); 34 | else 35 | handler.postDelayed(runnableTurnOn, timeout); 36 | } 37 | } 38 | } 39 | 40 | private Runnable runnableTurnOn = new Runnable() { 41 | @Override 42 | public void run() { 43 | CV.logi("sensor: turn on thread"); 44 | turnOn(); 45 | resetHandler(); 46 | } 47 | }; 48 | 49 | private void resetHandler(){ 50 | CV.logv("reset Handler"); 51 | handler.removeMessages(CALLBACK_EXISTS); 52 | handler.removeCallbacks(runnableTurnOn); 53 | } 54 | 55 | private void turnOn(){ 56 | if (!screenLock.isHeld()) { 57 | screenLock.acquire(); 58 | /* 59 | KeyguardManager mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); 60 | KeyguardManager.KeyguardLock mLock = mKeyGuardManager.newKeyguardLock("com.danielkao.autoscreenonoff"); 61 | if(mKeyGuardManager.isKeyguardLocked()) 62 | mLock.disableKeyguard(); 63 | mLock.reenableKeyguard(); 64 | */ 65 | new Thread(new Runnable() { 66 | public void run() { 67 | try { 68 | //Thread.sleep(1000); 69 | // try to fix phonepad and galaxy note's issue 70 | Thread.sleep(10000); 71 | } catch (InterruptedException e) { 72 | e.printStackTrace(); 73 | } 74 | if(screenLock.isHeld()) 75 | screenLock.release(); 76 | } 77 | }).start(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/strategy/BaseTurnOffStrategy.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.strategy; 2 | 3 | import android.content.Context; 4 | import android.media.AudioManager; 5 | import android.os.PowerManager.WakeLock; 6 | import android.os.Vibrator; 7 | import com.danielkao.autoscreenonoff.util.CV; 8 | 9 | /** 10 | * Created by plateau on 2013/09/12. 11 | */ 12 | public class BaseTurnOffStrategy extends BaseStrategy{ 13 | 14 | //handle timeout function 15 | private int CALLBACK_EXISTS=0; 16 | 17 | protected AudioManager am; 18 | 19 | public BaseTurnOffStrategy(Context context, WakeLock screenLock) { 20 | super(context,screenLock); 21 | am = (AudioManager)context.getSystemService(context.AUDIO_SERVICE); 22 | } 23 | 24 | @Override 25 | public void process(float sensorValue) { 26 | super.process(sensorValue); 27 | 28 | if (sensorValue == 0f) { 29 | if (mPowerManager.isScreenOn()) { 30 | // check if it is disabled during landscape mode, and now it's really in landscape 31 | // --> return 32 | /* 33 | if(CV.getPrefDisableInLandscape(context) && isOrientationLandscape()){ 34 | return; 35 | } 36 | else{ 37 | */ 38 | { 39 | long timeout = (long) CV.getPrefTimeoutLock(context); 40 | if(timeout == 0) 41 | turnOff(); 42 | else 43 | handler.postDelayed(runnableTurnOff, timeout); 44 | } 45 | } 46 | } 47 | // uncover 48 | else { 49 | } 50 | } 51 | 52 | protected void turnOff(){ 53 | CV.logv("sensor: turn off thread"); 54 | if(screenLock.isHeld()) 55 | screenLock.release(); 56 | deviceManager.lockNow(); 57 | playCloseSound(); 58 | vibrateWhileClose(); 59 | 60 | } 61 | 62 | private void playCloseSound(){ 63 | if(CV.getPrefPlayCloseSound(context)){ 64 | float vol = 1.0f; 65 | am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD, vol); 66 | } 67 | } 68 | 69 | private void vibrateWhileClose(){ 70 | if(CV.getVibrateWhileClose(context)){ 71 | Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); 72 | // Vibrate for 500 milliseconds 73 | v.vibrate(200); 74 | } 75 | } 76 | 77 | protected void resetHandler(){ 78 | CV.logv("reset Handler"); 79 | handler.removeMessages(CALLBACK_EXISTS); 80 | handler.removeCallbacks(runnableTurnOff); 81 | } 82 | 83 | private Runnable runnableTurnOff = new Runnable() { 84 | @Override 85 | public void run() { 86 | turnOff(); 87 | resetHandler(); 88 | } 89 | }; 90 | } 91 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/ui/TimePreference.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.ui; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.preference.DialogPreference; 6 | import android.util.AttributeSet; 7 | import android.view.View; 8 | import android.widget.TimePicker; 9 | 10 | /** 11 | * Created by plateau on 2013/06/04. 12 | */ 13 | public class TimePreference extends DialogPreference{ 14 | private int lastHour=0; 15 | private int lastMinute=0; 16 | private TimePicker picker=null; 17 | 18 | public TimePreference(Context context, AttributeSet attrs) { 19 | super(context, attrs); 20 | setPositiveButtonText("Dismiss"); 21 | } 22 | 23 | public static int getHour(String time) { 24 | String[] pieces=time.split(":"); 25 | 26 | return(Integer.parseInt(pieces[0])); 27 | } 28 | 29 | public static int getMinute(String time) { 30 | String[] pieces=time.split(":"); 31 | 32 | return(Integer.parseInt(pieces[1])); 33 | } 34 | 35 | @Override 36 | protected View onCreateDialogView() { 37 | picker=new TimePicker(getContext()); 38 | picker.setIs24HourView(true); 39 | 40 | return(picker); 41 | } 42 | 43 | @Override 44 | protected void onBindDialogView(View v) { 45 | super.onBindDialogView(v); 46 | 47 | picker.setCurrentHour(lastHour); 48 | picker.setCurrentMinute(lastMinute); 49 | } 50 | 51 | @Override 52 | protected void onDialogClosed(boolean positiveResult) { 53 | super.onDialogClosed(positiveResult); 54 | 55 | if (positiveResult) { 56 | lastHour=picker.getCurrentHour(); 57 | lastMinute=picker.getCurrentMinute(); 58 | String minute = String.valueOf(lastMinute); 59 | if(lastMinute<10) 60 | minute = "0" + String.valueOf(lastMinute); 61 | else 62 | minute = String.valueOf(lastMinute); 63 | 64 | 65 | String time=String.valueOf(lastHour)+":"+minute; 66 | 67 | setSummary(time); 68 | 69 | persistString(time); 70 | callChangeListener(time); 71 | } 72 | } 73 | 74 | @Override 75 | protected Object onGetDefaultValue(TypedArray a, int index) { 76 | return(a.getString(index)); 77 | } 78 | 79 | @Override 80 | protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { 81 | String time=null; 82 | 83 | if (restoreValue) { 84 | if (defaultValue==null) { 85 | time=getPersistedString("00:00"); 86 | } 87 | else { 88 | time=getPersistedString(defaultValue.toString()); 89 | } 90 | } 91 | else { 92 | time=defaultValue.toString(); 93 | } 94 | 95 | // set summary to real values 96 | setSummary(time); 97 | 98 | lastHour=getHour(time); 99 | lastMinute=getMinute(time); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/provider/ToggleAutoScreenOnOffAppWidgetProvider.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.provider; 2 | 3 | import android.app.PendingIntent; 4 | import android.appwidget.AppWidgetManager; 5 | import android.appwidget.AppWidgetProvider; 6 | import android.content.ComponentName; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.widget.RemoteViews; 10 | import com.danielkao.autoscreenonoff.R; 11 | import com.danielkao.autoscreenonoff.util.CV; 12 | 13 | public class ToggleAutoScreenOnOffAppWidgetProvider extends AppWidgetProvider { 14 | 15 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, 16 | int[] appWidgetIds) { 17 | final int N = appWidgetIds.length; 18 | 19 | // Perform this loop procedure for each App Widget that belongs to this 20 | // provider 21 | for (int i = 0; i < N; i++) { 22 | CV.logv("onUpdate in AppWidget"); 23 | int appWidgetId = appWidgetIds[i]; 24 | updateRemoteViews(context, appWidgetManager, appWidgetId,false); 25 | } 26 | } 27 | 28 | @Override 29 | public void onReceive(Context context, Intent intent) { 30 | super.onReceive(context, intent); 31 | 32 | String strAction = intent.getAction(); 33 | if (CV.UPDATE_WIDGET_ACTION.equals(strAction)){ 34 | boolean b = intent.getBooleanExtra(CV.PREF_CHARGING_ON, false); 35 | CV.logv("update widget action is received:%b", b); 36 | 37 | ComponentName thisAppWidget = new ComponentName(context.getPackageName(), 38 | getClass().getName()); 39 | AppWidgetManager awm = AppWidgetManager.getInstance(context); 40 | 41 | //Toast.makeText(context,"onReceive", Toast.LENGTH_SHORT); 42 | 43 | int ids[] = awm.getAppWidgetIds(thisAppWidget); 44 | 45 | // no widgets yet, return 46 | if (ids.length == 0)return; 47 | 48 | // widget exists, update all 49 | for(int appWidgetID : ids) 50 | updateRemoteViews(context, awm, appWidgetID,b); 51 | 52 | } 53 | } 54 | 55 | private void updateRemoteViews(Context context, AppWidgetManager awm, int appWidgetId, boolean isCharging){ 56 | CV.logv("onUpdate in AppWidget"); 57 | 58 | Intent intent = new Intent(CV.SERVICE_INTENT_ACTION); 59 | intent.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_TOGGLE); 60 | intent.putExtra(CV.SERVICETYPE, CV.SERVICETYPE_WIDGET); 61 | intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); 62 | 63 | PendingIntent pendingIntent = PendingIntent.getService(context, 0, 64 | intent, PendingIntent.FLAG_UPDATE_CURRENT); 65 | 66 | // Get the layout for the App Widget and attach an on-click listener 67 | // to the button 68 | RemoteViews views = new RemoteViews(context.getPackageName(), 69 | R.layout.toggleonoff_appwidget); 70 | views.setOnClickPendingIntent(R.id.imageview, pendingIntent); 71 | 72 | // ------ change images!! 73 | boolean autoOn = CV.getPrefAutoOnoff(context); 74 | if (autoOn) { 75 | // set icon to on 76 | views.setImageViewResource(R.id.imageview, R.drawable.widget_on); 77 | } else { 78 | // check whether charging_on is on and it's under charging state 79 | if((isCharging || CV.isPlugged(context)) 80 | && CV.getPrefChargingOn(context)) { 81 | views.setImageViewResource(R.id.imageview, R.drawable.widget_charging_on); 82 | } else{ 83 | // set icon to off 84 | views.setImageViewResource(R.id.imageview, R.drawable.widget_off); 85 | } 86 | } 87 | // ------ change images!! end 88 | 89 | // Tell the AppWidgetManager to perform an update on the current app widget 90 | awm.updateAppWidget(appWidgetId, views); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/ui/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.ui; 2 | 3 | import android.app.Activity; 4 | import android.app.admin.DevicePolicyManager; 5 | import android.content.*; 6 | import android.os.Bundle; 7 | import android.os.IBinder; 8 | import android.util.Log; 9 | import com.danielkao.autoscreenonoff.R; 10 | import com.danielkao.autoscreenonoff.receiver.TurnOffReceiver; 11 | import com.danielkao.autoscreenonoff.service.SensorMonitorService; 12 | import com.danielkao.autoscreenonoff.service.SensorMonitorService.LocalBinder; 13 | import com.danielkao.autoscreenonoff.util.CV; 14 | 15 | public class MainActivity extends Activity { 16 | 17 | private static final int REQUEST_CODE_ENABLE_ADMIN = 1; 18 | private static final String TAG = "TurnOff"; 19 | 20 | private DevicePolicyManager deviceManager; 21 | private ComponentName mDeviceAdmin; 22 | 23 | //service 24 | private SensorMonitorService sensorService; 25 | 26 | // check if intent is from screenOff request 27 | private boolean bCloseAfter = false; 28 | 29 | @Override 30 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 31 | super.onActivityResult(requestCode, resultCode, data); 32 | if (REQUEST_CODE_ENABLE_ADMIN == requestCode) 33 | { 34 | if (resultCode == Activity.RESULT_OK) { 35 | Log.v(TAG, "add device admin okay!!"); 36 | // Has become the device administrator. 37 | if(bCloseAfter){ 38 | shutdown(); 39 | bCloseAfter=false; 40 | } 41 | } else { 42 | //Canceled or failed: turn off Enabler 43 | Log.v(TAG, "add device admin not okay"); 44 | 45 | } 46 | finish(); 47 | } 48 | } 49 | 50 | @Override 51 | protected void onCreate(Bundle savedInstanceState) { 52 | super.onCreate(savedInstanceState); 53 | 54 | deviceManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); 55 | mDeviceAdmin = new ComponentName(this, TurnOffReceiver.class); 56 | 57 | // get value from intent 58 | Intent i = getIntent(); 59 | if(null != i){ 60 | bCloseAfter = i.getBooleanExtra(CV.CLOSE_AFTER,false); 61 | } 62 | 63 | // handle activeAdmin previlige 64 | if(!isActiveAdmin()) 65 | { 66 | sendDeviceAdminIntent(); 67 | return; 68 | } 69 | } 70 | 71 | 72 | @Override 73 | protected void onStop() { 74 | super.onStop(); 75 | if(sensorService != null) 76 | unbindService(mConnection); 77 | } 78 | 79 | @Override 80 | protected void onDestroy() { 81 | super.onDestroy(); 82 | } 83 | 84 | private boolean isActiveAdmin() { 85 | return deviceManager.isAdminActive(mDeviceAdmin); 86 | } 87 | 88 | private void sendDeviceAdminIntent(){ 89 | Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); 90 | intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdmin); 91 | intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, 92 | getResources().getString(R.string.device_management_explanation)); 93 | //"Need this privilege to turn off the screen"); 94 | startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN); 95 | 96 | } 97 | 98 | private void shutdown(){ 99 | deviceManager.lockNow(); 100 | } 101 | 102 | // service connection 103 | private ServiceConnection mConnection = new ServiceConnection() { 104 | @Override 105 | public void onServiceConnected(ComponentName className, IBinder service) { 106 | // We've bound to LocalService, cast the IBinder and get LocalService instance 107 | LocalBinder binder = (LocalBinder) service; 108 | sensorService = binder.getService(); 109 | if(CV.getPrefAutoOnoff(MainActivity.this)){ 110 | sensorService.registerSensor(); 111 | } 112 | else { 113 | sensorService.unregisterSensor(); 114 | finish(); 115 | } 116 | } 117 | 118 | @Override 119 | public void onServiceDisconnected(ComponentName arg0) { 120 | } 121 | }; 122 | } 123 | -------------------------------------------------------------------------------- /PowerOffTest/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /PowerOff.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /res/values-nl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AutoScreenOnOff 5 | Auto Screen Instellingen 6 | Instellingen 7 | Hallo wereld! 8 | 9 | Set AutoScreen AAN 10 | Set AutoScreen UIT 11 | Need this privilege to turn off the screen 12 | Screen OnOff 13 | 14 | Auto Screen Instellingen 15 | Power Instellingen 16 | Geavanceerd 17 | 18 | werkt alleen tijdens opladen. 19 | Alleen wanneer in Oplader 20 | 21 | Screen On/Off automatisch 22 | Inschakelen 23 | Uninstall 24 | 25 | Rank my App! 26 | Naar GitHub 27 | Over 28 | Wat Is er nieuw? 29 | 30 | Useful for taking photos or watching movies in landscape. 31 | Tijdelijk gedeactiveerd in Landscape 32 | 33 | Over 34 | %s\nv%s 35 | 36 | Vertraging wanneer Scherm UIT word geactiveerd. \n\nCurrent setting:%s 37 | Scherm Uit Timeout Waarde 38 | 39 | Vertraging wanneer scherm AAN word geactiveerd. \n\nCurrent setting:%s 40 | Scherm Aan Timeout Waarde 41 | 42 | WERKT ALLEEN op SOMMIGE apparaten. Op andere apparaten, werkt de aan/uit functie niet goed. Probeer het zelf. 43 | Besparings Mode 44 | 45 | Zelfde als schermbeveiligings Tijd 46 | Direct 47 | 0.5 sec 48 | 1 sec 49 | 2 sec 50 | 3 sec 51 | 10 sec 52 | Twee Keer Swipe 53 | Nooit 54 | 55 | Deinstalleer App 56 | Wil je echt deze app verwijderen? 57 | 58 | Slaaptijd Instellingen (Beta) 59 | om Batterij verbruik te verminderen.(nog in beta. als je fouten vind contacteer mij.) 60 | Uitgeschakeld in Slaap 61 | Slaap Start Tijd 62 | Slaap Stop Tijd 63 | 64 | Snellere toggle;met scherm uit-knop 65 | Laat Notificatie zien 66 | Opladen! AutoScreen is actief. 67 | AutoScreen is actief. 68 | AutoScreen is Gedeactiveerd. 69 | 70 | 71 | https://github.com/plateaukao/PowerOff 72 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 73 | Speel geluid wanner scherm uit is. 74 | Play Close Sound 75 | 76 | 77 | Aan/Uit verwante Instellingen 78 | 79 | Verstuur feedback 80 | Er zijn geen e-mail accounts geinstalleerd. 81 | Feedback van autoscreenonoff app 82 | -------------------------------------------------------------------------------- /res/xml/widget_configure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 17 | 18 | 25 | 26 | 31 | 32 | 37 | 38 | 43 | 44 | 49 | 50 | 55 | 56 | 63 | 64 | 71 | 72 | 73 | 74 | 75 | 80 | 81 | 86 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /res/xml-v14/widget_configure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 17 | 18 | 25 | 26 | 31 | 32 | 37 | 38 | 43 | 44 | 49 | 50 | 55 | 56 | 57 | 60 | 67 | 68 | 75 | 76 | 77 | 78 | 79 | 84 | 85 | 90 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 36 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 60 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 88 | 89 | 90 | 91 | 92 | 93 | 96 | 97 | 98 | 99 | 100 | 101 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /res/values-zh/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 自動螢幕開關 4 | 設定 5 | Hello world! 6 | 啟動螢幕自動控制 7 | 關閉螢幕自動控制 8 | 需要此權限,才可以關閉螢幕 9 | 自動螢幕開關 10 | 11 | 給我評價 12 | 前往 GitHub 13 | 關於 14 | 最近更新記錄 15 | 16 | 關於 17 | %s\n版本:%s 18 | 19 | 自動螢幕控制設定 20 | 進階 21 | 22 | 自動螢幕控制 23 | 插入電源時的設定 24 | 25 | 當接上 USB 線時開啟本功能;當拔出 USB 時自動關閉本功能。 26 | 僅在接上電源時啟動 27 | 28 | 當"測近感側器"被遮蓋時,畫面自動關閉;當無遮蓋時則自動點亮畫面。 29 | 啟動 30 | 移除 31 | 32 | 手機橫放時暫不關閉螢幕。適用於看影片或是拍照。 33 | 橫屏時暫時無作用 34 | 35 | 遮蓋時,延遲多久才關閉畫面。可避免誤觸\n\n目前設定: %s 36 | 關閉畫面延遲 37 | 開蓋時,延遲多久才開啟畫面。\n\n目前設定: %s 38 | 開啟畫面延遲 39 | 40 | 與關閉畫面延遲相同 41 | 立即作用 42 | 0.5 秒 43 | 1 秒 44 | 2 秒 45 | 3 秒 46 | 10 秒 47 | 感應器上手划兩下 48 | 不使用此功能 49 | 50 | 移除軟體 51 | 你確定要移除本軟體嗎? 52 | 53 | 54 | Version 2.7 (2015/02/06) 56 |
    57 |
  • 電話通話中,暫停作用
  • 58 |
  • 修正在 Android 5,例外軟體列表無作用
  • 59 |
  • 嘗試修正睡眠功能失效的問題
  • 60 |
61 | ]]> 62 |
63 | 64 | Version 2.6 (2014/07/22) 66 |
    67 |
  • 不想太耗電的人,現在可以直接在Home加上個關閉螢幕的小工具!
  • 68 |
69 | ]]> 70 |
71 | 72 | Version 2.5 (2014/07/19) 74 |
    75 |
  • 等待已久的功能:可以選擇在哪些 app 中,不要自動關閉畫面!
  • 76 |
77 | Version 2.4.2 (2014/07/06) 78 |
    79 |
  • 加入德文、俄文、烏克蘭文翻譯, Thanks to Paul L. Scholz, and Andrew
  • 80 |
81 | Version 2.4 (2014/02/15) 82 |
    83 |
  • 移除解鎖的測試功能
  • 84 |
  • 解決在某些手機上會crash的問題
  • 85 |
86 | Version 2.3 (2014/02/14) 87 |
    88 |
  • 荷文翻譯:謝謝 Xander Stone
  • 89 |
  • 新功能: 關閉螢幕時可震動
  • 90 |
  • 改進: 將移除軟體的按鈕變得更明顯。別再問我怎麼移除了!
  • 91 |
  • 改進: 睡眠時間設定改為24小時制
  • 92 |
93 | Version 2.2 (2013/12/02): 94 |
    95 |
  • 新功能:增加手划兩下啟動或關閉畫面,在 畫面延遲 中可設定
  • 96 |
  • 新功能:增加 個別取消 啟動或關閉畫面功能,在 畫面延遲 中可設定
  • 97 |
98 | Version 2.1.0 (2013/08/19): 99 |
    100 |
  • 新功能:螢幕關閉時,會發出聲音
  • 101 |
  • 增加法文翻譯,感謝 Geoffrey Frogeye 的協助
  • 102 |
103 | Version 2.0.10 (2013/08/04): 104 |
    105 |
  • 解問題:增加橫畫面暫時停用的靈敏度,作用範圍由原先的15度改為45度
  • 106 |
  • 增加越南文翻譯,感謝 Hai Long Hoang 的協助
  • 107 |
108 | Version 2.0.9 (2013/07/04): 109 |
    110 |
  • 解問題:功能開啟後,滑動設定畫面,會造成功能自動關閉(Google的問題…)
  • 111 |
112 | Version 2.0.8 (2013/06/30): 113 |
    114 |
  • 功能:省電模式 (只可作用在部分手機。請自己試用,確定不會影響原本的功能,再行使用)
  • 115 |
  • 解問題:重開機之後,睡眠時間沒作用。
  • 116 |
  • 解問題:三星手機上,螢幕一亮就會馬上暗掉的問題,應該解了(我沒三星手機,只能試著解解看,但不確定)
  • 117 |
118 | 版本 2.0.7 (2013/06/20): 119 |
    120 |
  • 會造成部分設備無法正常叫醒螢幕:加回 partial wakelock
  • 121 |
122 | 版本 2.0.6 (2013/06/19): 123 |
    124 |
  • 減少耗電量 (移除partial wakelock) 125 |
126 | 版本 2.0.5 (2013/06/15): 127 |
    128 |
  • 解決在睡眠時間結束後,本功能沒有自動再開啟 129 |
130 | 版本 2.0.4 (2013/06/13): 131 |
    132 |
  • 解決在android 2.3機器上程式執行中止的問題 133 |
134 | 版本 2.0.3 (2013/06/11): 135 |
    136 |
  • 加強:調整感應器參數。更加省電。 137 |
138 | 版本 2.0.2 (2013/06/10): 139 |
    140 |
  • 解決有時候通知欄裡的圖案,點擊無效的問題。 141 |
  • 安裝完新版後,會自動再將服務開啟。 142 |
143 | 版本 2.0.1 (2013/06/08): 144 |
    145 |
  • 解2.x 手機上的問題:如果訊息顯示會報錯誤,請裝這版更新。 146 |
  • 將\"移除軟體\"移到畫面上方工具列,節省下方空間。 147 |
148 | 版本 2.0 (2013/06/07): 149 |
    150 |
  • 新增訊息顯示:讓你可以更快速地在訊息欄中啟動本功能。最左邊會啟動app,最右邊紅色按鈕可以單純關閉螢幕。中間按鈕則可以用來快速開關本功能。
  • 151 |
152 | 版本 1.9: 153 |
    154 |
  • 大幅縮減app的檔案大小(小於100K)
  • 155 |
  • 新增睡眠時間設定,可以有效降低耗電量
  • 156 |
  • 更新軟體圖案
  • 157 |
  • 修正有時\"插電時啟動\"會失效的問題
  • 158 |
159 | 版本 1.8: 160 |
    161 |
  • 重開機後自動生效
  • 162 |
  • 升級後,顯示版本更新內容
  • 163 |
  • 設定中的延遲時間可以正常顯示更新
  • 164 |
165 | ]]> 166 |
167 | 168 | 睡眠時間設定(測試中功能) 169 | 可有效減少耗電量(仍在測試中,有問題請幫忙回報,謝謝) 170 | 睡眠時間無作用 171 | 睡眠開始時間 172 | 睡眠結束時間 173 | 174 | 只適用於某些手機。\n其他手機會造成原本功能常會失效。請自行試用看看。正常的話再使用 175 | 省電模式! 176 | 177 | 快速開關,包含一顆關閉螢幕的按鈕 178 | 顯示在訊息欄內 179 | 充電中!開啟自動螢幕控制 180 | 開啟 自動螢幕控制 181 | 關閉 自動螢幕控制 182 | 關閉螢幕時播放提示音效 183 | 播放關閉音效 184 | 185 | 在哪些app中不要自動關閉畫面 186 |
-------------------------------------------------------------------------------- /res/values-cs/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Nastavení 4 | AutoScreenOnOff 5 | https://github.com/plateaukao/PowerOff 6 | 7 | Version 2.5 (2014/07/19) 9 |
    10 |
  • long awaited feature! Now you can select which apps to exclude!
  • 11 |
12 | Version 2.4.2 (2014/07/06) 13 |
    14 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 15 |
16 | Version 2.4 (2014/02/15) 17 |
    18 |
  • Remove testing unlock feature
  • 19 |
  • fix crashes on some devices
  • 20 |
21 | Version 2.3 (2014/02/14) 22 |
    23 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 24 |
  • Improvement: Add Vibrate while turning off screen.
  • 25 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 26 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 27 |
28 | Version 2.2 (2013/12/02): 29 |
    30 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 31 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 32 |
33 | Version 2.1.0 (2013/08/19) 34 |
  • Improvement: It\'s possible to hear cover close sound now
  • Add French translation: Thanks for Geoffrey Frogeye\' help
Version 2.0.10 (2013/08/04):
  • Improvement: Improves sensitivity of Landscape disabling
  • Add Vietnamese translation: Thanks for Hai Long Hoang\' help
Version 2.0.9 (2013/07/04):
  • Issue Fix: Turning on feature, and scroll settings, it will cause turn off feature (Google\'s issue)
Version 2.0.8 (2013/06/30):
  • Feature: Add Power Save Mode. ONLY Works on Some devices. If it makes screen on/off not working. Don\'t use it.
  • Issue Fix: Sleeping time not working, after rebooting the device.
  • Issue Fix: Auto turn on Screen (but turn off right away) should work normally on Samsung devices now. I hope so, since I don\'t have one to verify.
Version 2.0.7 (2013/06/20):
  • Add partial wakelock back
Version 2.0.6 (2013/06/19):
  • Reduce power consumption by removing partial wakelock
Version 2.0.5 (2013/06/15):
  • Issue fix: When sleep time is up, the function is not enabled again.
Version 2.0.4 (2013/06/13):
  • Issue fix: fix crash issue on android 2.x devices.
Version 2.0.3 (2013/06/11):
  • Fine tuning: fine tune sensor parameter in order to save more power.
Version 2.0.2 (2013/06/10):
  • Issue fix: some people may encounter notification not working issue. it\'s fixed in this version
  • Restart service after upgrading app.
Version 2.0.1 (2013/06/08):
  • Issue fix: if you are using Android 2.x devices, make sure you update this version, so that notification can work for you.
  • Move \"Uninstall App\" button to actionbar; make room for preferences.
Version 2.0 (2013/06/07):
  • Add notification: now you can toggle the feature more conveniently!
Version 1.9:
  • Largely shrink the app file size by removing unwanted libs
  • Add sleep time settings, to better reduce power consumption.
  • Change application logo icon
  • Issue fix: sometimes \"Enable while plugged\" can\'t function well.
Version 1.8:
  • works after rebooting the device. You don\'t have to manually turn on the function again.
  • A version changelog dialog is added. Every time a new version arrives, it\'s easier for you to know what\'s been added.
  • Timeout value can be correctly updated now!
  • 35 |
36 | ]]> 37 |
38 | Potřebujete oprávnění pro vypnutí obrazovky 39 | "%s 40 | v%s" 41 | O aplikaci 42 | Opravdu chcete odinstalovat tuto aplikaci? 43 | Odinstalovat App 44 | Ahoj všichni! 45 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 46 | Pokročilé 47 | Nastavení AutoScreen 48 | Přehrát zvuk, při automatickém vypnutí obrazovky 49 | Nastavení Napájení 50 | Nastavení Času Spánku (Beta) 51 | Obrazovka Zap/Vyp automaticky 52 | funguje pouze při nabíjení. 53 | Vhodné pro pořizování fotografií nebo sledování filmů v landscape módu (Na šířku). 54 | FUNGUJE POUZE na NĚKTERÝCH ZAŘÍZENÍCH. Na jiných zařízeních, funkce zapnutí/vypnutí nemusí fungovat správně. Zkuste sami. 55 | Rychlejší přepínání; také včetně obrazovky vyp 56 | z důvodu úspory energie(Stále buggy. Hlásit mě, jestli najdete chybu.) 57 | "Zpoždění než se Obrazovka Vypne. 58 | 59 | Aktuální nastavení:%s" 60 | "Zpoždění než se Obrazovka Zapne. 61 | 62 | Aktuální nastavení:%s" 63 | Povolit 64 | Pouze tehdy, když je připojen 65 | Dočasně zakázat v Landscape módu 66 | Úsporný Režim 67 | Přehrát Zvuk Vypnutí 68 | Zobrazit Oznámení v Panelu 69 | Vypnout při Spánku 70 | Časový limit Vypnutí Obrazovky 71 | Časový limit Zapnutí Obrazovky 72 | AutoScreenOnOff 73 | Spánek Čas Začátku 74 | Spánek Čas Ukončení 75 | AutoScreen je Zakázán. 76 | AutoScreen je Povolen. 77 | Nabíjení! AutoScreen je Povoleno. 78 | Okamžitě 79 | 0.5 sek 80 | 1 sek 81 | 2 sek 82 | 3 sek 83 | 10 sek 84 | Stejný Časový Limit jako Zámek 85 | O aplikaci 86 | "Co je nového" 87 | Jít na GitHub 88 | Ohodnoť mojí App! 89 | Vypnout AutoScreen VYP 90 | Zapnout AutoScreen ZAP 91 | Odinstalovat App 92 | AutoScreen OnOff 93 |
94 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/ui/AppMultiselectListPreference.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.ui; 2 | 3 | import android.app.AlertDialog.Builder; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.content.DialogInterface.OnMultiChoiceClickListener; 7 | import android.content.Intent; 8 | import android.content.pm.PackageManager; 9 | import android.content.pm.ResolveInfo; 10 | import android.content.res.Resources; 11 | import android.preference.ListPreference; 12 | import android.util.AttributeSet; 13 | import android.util.Log; 14 | import com.danielkao.autoscreenonoff.util.CV; 15 | 16 | import java.util.*; 17 | 18 | /** 19 | * Created by plateau on 2014/07/19. 20 | */ 21 | public class AppMultiselectListPreference extends ListPreference { 22 | 23 | private class AppInfo { 24 | public AppInfo(String name, String appPackageName) { 25 | this.appName = name; 26 | this.appPackageName = appPackageName; 27 | } 28 | 29 | public String appName; 30 | public String appPackageName; 31 | } 32 | 33 | private String separator; 34 | private static final String DEFAULT_SEPARATOR = "\u0001\u0007\u001D\u0007\u0001"; 35 | private boolean[] entryChecked; 36 | private CharSequence[] entries; 37 | private CharSequence[] entryValues; 38 | 39 | public AppMultiselectListPreference(Context context, AttributeSet attributeSet) { 40 | super(context, attributeSet); 41 | separator = DEFAULT_SEPARATOR; 42 | setSummary(prepareSummary(null)); 43 | } 44 | 45 | public AppMultiselectListPreference(Context context) { 46 | this(context, null); 47 | setSummary(prepareSummary(null)); 48 | } 49 | 50 | @Override 51 | protected void onPrepareDialogBuilder(Builder builder) { 52 | List appList = getInstalledComponentList(); 53 | entries = new CharSequence[appList.size()]; 54 | entryValues = new CharSequence[appList.size()]; 55 | for (int i = 0 ; i < appList.size(); i++) { 56 | entries[i] = appList.get(i).appName; 57 | } 58 | for (int i = 0 ; i < appList.size(); i++) { 59 | entryValues[i] = appList.get(i).appPackageName; 60 | } 61 | 62 | entryChecked = new boolean[appList.size()]; 63 | 64 | restoreCheckedEntries(); 65 | 66 | OnMultiChoiceClickListener listener = new DialogInterface.OnMultiChoiceClickListener() { 67 | public void onClick(DialogInterface dialog, int which, boolean val) { 68 | entryChecked[which] = val; 69 | Log.v("applist", entryValues[which].toString()); 70 | } 71 | }; 72 | 73 | builder.setMultiChoiceItems(entries, entryChecked, listener); 74 | } 75 | 76 | private CharSequence[] unpack(CharSequence val) { 77 | if (val == null || "".equals(val)) { 78 | return new CharSequence[0]; 79 | } else { 80 | return ((String) val).split(separator); 81 | } 82 | } 83 | /** 84 | * Gets the entries values that are selected 85 | * 86 | * @return the selected entries values 87 | */ 88 | public CharSequence[] getCheckedValues() { 89 | return unpack(getValue()); 90 | } 91 | 92 | private List getInstalledComponentList(){ 93 | final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); 94 | Context context = getContext(); 95 | mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); 96 | List ril = context.getPackageManager().queryIntentActivities(mainIntent, 0); 97 | if(ril == null) return null; 98 | 99 | List componentList = new ArrayList(); 100 | String name = null; 101 | 102 | for (ResolveInfo ri : ril) { 103 | if (ri.activityInfo != null) { 104 | try { 105 | Resources res = context.getPackageManager().getResourcesForApplication(ri.activityInfo.applicationInfo); 106 | if (ri.activityInfo.labelRes != 0) { 107 | name = res.getString(ri.activityInfo.labelRes); 108 | } else { 109 | name = ri.activityInfo.applicationInfo.loadLabel( 110 | context.getPackageManager()).toString(); 111 | } 112 | 113 | Log.v("applist", name); 114 | componentList.add(new AppInfo(name, ri.activityInfo.processName)); 115 | } catch (PackageManager.NameNotFoundException e) { 116 | e.printStackTrace(); 117 | } 118 | } 119 | } 120 | Collections.sort(componentList, new Comparator() { 121 | @Override 122 | public int compare(AppInfo lhs, AppInfo rhs) { 123 | return lhs.appName.compareTo(rhs.appName); 124 | } 125 | }); 126 | return componentList; 127 | } 128 | 129 | private void restoreCheckedEntries() { 130 | // Explode the string read in sharedpreferences 131 | CharSequence[] vals = unpack(getValue()); 132 | 133 | if (vals != null) { 134 | List valuesList = Arrays.asList(vals); 135 | for (int i = 0; i < entryValues.length; i++) { 136 | CharSequence entry = entryValues[i]; 137 | entryChecked[i] = valuesList.contains(entry); 138 | } 139 | } 140 | } 141 | 142 | @Override 143 | protected void onDialogClosed(boolean positiveResult) { 144 | List values = new ArrayList(); 145 | 146 | if (positiveResult && entryValues != null) { 147 | for (int i = 0; i < entryValues.length; i++) { 148 | if (entryChecked[i] == true) { 149 | String val = (String) entryValues[i]; 150 | values.add(val); 151 | } 152 | } 153 | 154 | String value = join(values, separator); 155 | String names = (String)prepareSummary(values); 156 | setSummary(names); 157 | /* set summary value to preference too */ 158 | CV.setExcludeAppNameList(getContext(), names); 159 | /* */ 160 | setValueAndEvent(value); 161 | } 162 | } 163 | 164 | private void setValueAndEvent(String value) { 165 | if (callChangeListener(unpack(value))) { 166 | setValue(value); 167 | } 168 | } 169 | 170 | private CharSequence prepareSummary(List joined) { 171 | List titles = new ArrayList(); 172 | CharSequence[] entryTitle = entries; 173 | if (entries == null || entries.length == 0) { 174 | return CV.getExcludeAppNameList(getContext()); 175 | } 176 | 177 | int ix = 0; 178 | for (CharSequence value : entryValues) { 179 | if (joined.contains(value)) { 180 | titles.add((String) entryTitle[ix]); 181 | } 182 | ix += 1; 183 | } 184 | return join(titles, ", "); 185 | } 186 | 187 | /* 188 | @Override 189 | protected Object onGetDefaultValue(TypedArray typedArray, int index) { 190 | return typedArray.getTextArray(index); 191 | } 192 | */ 193 | 194 | /* 195 | @Override 196 | protected void onSetInitialValue(boolean restoreValue, 197 | Object rawDefaultValue) { 198 | setSummary(prepareSummary(null)); 199 | } 200 | */ 201 | 202 | /** 203 | * Joins array of object to single string by separator 204 | * 205 | * Credits to kurellajunior on this post 206 | * http://snippets.dzone.com/posts/show/91 207 | * 208 | * @param iterable 209 | * any kind of iterable ex.: ["a", "b", "c"] 210 | * @param separator 211 | * separetes entries ex.: "," 212 | * @return joined string ex.: "a,b,c" 213 | */ 214 | protected static String join(Iterable iterable, String separator) { 215 | Iterator oIter; 216 | if (iterable == null || (!(oIter = iterable.iterator()).hasNext())) 217 | return ""; 218 | StringBuilder oBuilder = new StringBuilder(String.valueOf(oIter.next())); 219 | while (oIter.hasNext()) 220 | oBuilder.append(separator).append(oIter.next()); 221 | return oBuilder.toString(); 222 | } 223 | 224 | } 225 | -------------------------------------------------------------------------------- /res/values-vi/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tự động tắt/mở màn hình 5 | Cài đặt màn hình tự động tắt/mở 6 | Cài đặt 7 | Xin chào! 8 | 9 | Mở tự động tắt/mở 10 | Tắt tự động tắt/mở 11 | Cần quyền này để tắt màn hình 12 | Tắt/mở màn hình 13 | 14 | Cài đặt màn hình tự động 15 | Cài đặt pin 16 | Nâng cao 17 | 18 | Chỉ chạy khi sạc. 19 | Chỉ khi cắm sạc 20 | 21 | Màn hình tắt/mở tự động 22 | Kích hoạt 23 | Gỡ ứng dụng 24 | 25 | Bầu chọn cho ứng dụng! 26 | vào GitHub 27 | Thông tin 28 | Có gì mới? 29 | 30 | Tiện khi màn hình xoay ngang để chụp ảnh hay xem phim. 31 | Tạm dừng khi màn hình xoay ngang 32 | 33 | Thông tin 34 | %s\nv%s 35 | 36 | Độ trễ khi Tắt màn hình có hiệu lực. \n\nCài đặt hiện tại:%s 37 | Thời gian chờ Tắt màn hình 38 | 39 | Độ trễ khi Mở màn hình có hiệu lực. \n\nCài đặt hiện tại:%s 40 | Thời gian chờ Mở màn hình 41 | 42 | CHỈ HOẠT ĐỘNG với MỘT SỐ thiết bị. Trên vài thiết bị khác, tính năng tắt/mở sẽ không hoạt động tốt. Bạn hãy tự trải nghiệm. 43 | Tiết kiệm pin 44 | 45 | Bằng thời lượng khóa màn hình 46 | Ngay lập tức 47 | 0.5 giây 48 | 1 giây 49 | 2 giây 50 | 3 giây 51 | 10 giây 52 | 53 | Gỡ ứng dụng 54 | Bạn thực sự muốn gỡ ứng dụng? 55 | 56 | 57 | Version 2.5 (2014/07/19) 59 |
    60 |
  • long awaited feature! Now you can select which apps to exclude!
  • 61 |
62 | Version 2.4.2 (2014/07/06) 63 |
    64 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 65 |
66 | Version 2.4 (2014/02/15) 67 |
    68 |
  • Remove testing unlock feature
  • 69 |
  • fix crashes on some devices
  • 70 |
71 | Version 2.3 (2014/02/14) 72 |
    73 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 74 |
  • Improvement: Add Vibrate while turning off screen.
  • 75 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 76 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 77 |
78 | Version 2.2 (2013/12/02): 79 |
    80 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 81 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 82 |
83 | Version 2.0.10 (2013/08/04): 84 |
    85 |
  • *Cải tiến: Tăng cường độ nhạy cho tính năng \"Tạm dừng khi màn hình xoay ngang\"
  • 86 |
  • *Thêm ngôn ngữ tiếng Việt bởi Hoàng Hải Long
  • 87 |
88 | Bản 2.0.9 (2013/07/04): 89 |
    90 |
  • Sửa lỗi: Tính năng mở, và cuộn trong phần cài đặt, khiến tắt ứng dụng (vấn đề thuộc Google)
  • 91 |
92 | Bản 2.0.8 (2013/06/30): 93 |
    94 |
  • Tính năng: Thêm chế độ tiết kiệm pin. Chỉ chạy trên một số thiết bị. Nếu nó làm màn hình không tắt/mở. Thôi dùng nó.
  • 95 |
  • Sửa lỗi: Thời gian ngủ không hoạt động, sau khi khởi chạy máy.
  • 96 |
  • Sửa lỗi: Tự động mở màn hình (nhưng tắt ngay) hiện có thể chạy tốt trên các thiết bị Samsung. Mình hy vọng thế, Vì hiện mình không có máy để xác nhận.
  • 97 |
98 | Bản 2.0.7 (2013/06/20): 99 |
    100 |
  • Thêm trở lại phần tự khóa
  • 101 |
102 | Bản 2.0.6 (2013/06/19): 103 |
    104 |
  • Giảm tiêu hao điện năng bằng cách bỏ đi tính năng tự khóa
  • 105 |
106 | Bản 2.0.5 (2013/06/15): 107 |
    108 |
  • Sửa lỗi: Khi chỉnh tăng thời gian ngủ, tính năng không chạy lại.
  • 109 |
110 | Bản 2.0.4 (2013/06/13): 111 |
    112 |
  • Sửa lỗi: sửa lỗi treo ở các thiết bị chạy android 2.x.
  • 113 |
114 | Bản 2.0.3 (2013/06/11): 115 |
    116 |
  • Tinh chỉnh: tinh chỉnh các tham số ở cảm biến để thiết kiệm pin.
  • 117 |
118 | Bản 2.0.2 (2013/06/10): 119 |
    120 |
  • Sửa lỗi: vài người gặp phải vấn đề không hoạt động trên thanh thông báo. Bản này sẽ khắc phục nó.
  • 121 |
  • Khởi động lại ứng dụng sau khi nâng cấp.
  • 122 |
123 | Bản 2.0.1 (2013/06/08): 124 |
    125 |
  • Sửa lỗi: nếu bạn đang dùng thiết bị chạy Android 2.x, hãy dùng bản này, mục thông báo có thể sẽ hoạt động.
  • 126 |
  • Chuyển nút \"Gỡ ứng dụng\" lên thanh hoạt động; tạo không gian cho phần cài đặt.
  • 127 |
128 | Bản 2.0 (2013/06/07): 129 |
    130 |
  • Thêm mục thông báo: giờ bạn có thể truy cập các tính năng tiện hơn!
  • 131 |
132 | Bản 1.9: 133 |
    134 |
  • Thu gọn dung lượng ứng dụng đáng kể bằng cách bỏ các đoạn mã không cần thiết.
  • 135 |
  • Thêm cài đặt thời gian ngủ, để tiết kiệm pin tốt hơn.
  • 136 |
  • Đổi biểu tượng ứng dụng
  • 137 |
  • Sửa lỗi: thi thoảng tính năng \"Chạy khi cắm sạc\" không chạy tốt.
  • 138 |
139 | Bản 1.8: 140 |
    141 |
  • hoạt động sau khi khởi động lại máy. Bạn không phải mở tính năng lại.
  • 142 |
  • Thêm danh mục các thay đổi ở từng bản. Mỗi khi một bản mới có, bạn sẽ biết có gì mới dễ dàng hơn.
  • 143 |
  • Thời lượng có thể được cập nhật chính xác hơn!
  • 144 |
145 | ]]> 146 |
147 | 148 | Cài đặt khi ngủ (Beta) 149 | để giảm thiểu tiêu hao năng lượng.(Còn lỗi. Thông báo cho mình nếu bạn tìm thấy lỗi.) 150 | Dừng khi ngủ 151 | Thời điểm bắt đầu ngủ 152 | Thời điểm thức dậy 153 | 154 | Nút chuyển nhanh;gồm cả nút tắt màn hình 155 | Hiển thị trên thanh thông báo 156 | Đang sạc! Kích hoạt tự động tắt/mở màn hình. 157 | Đã kích hoạt màn hình tự động. 158 | Đã dừng màn hình tự động. 159 | 160 | 161 | https://github.com/plateaukao/PowerOff 162 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 163 | Play sound while auto turning off screen 164 | Play Close Sound 165 | 166 | 167 |
-------------------------------------------------------------------------------- /res/values-sk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AutoScreenOnOff 5 | Auto Screen nastavenia 6 | Nastavenia 7 | Hello world! 8 | 9 | AutoScreen ZAP 10 | AutoScreen VYP 11 | Je potrebné pre vypnutie obrazovky. 12 | Obrazovka ZAP/VYP 13 | 14 | Nastavenia Auto Screen 15 | Nastavenie napájania 16 | Pokročilé 17 | 18 | funguje iba pri nabíjaní. 19 | Iba ak je zariadenie pripojené 20 | 21 | vypínanie/zapínanie obrazovky automaticky 22 | Povoliť 23 | Odinštalovať aplikáciu 24 | 25 | Ohodnotiť aplikáciu! 26 | Ísť na GitHub 27 | O aplikácii 28 | Čo je nové 29 | 30 | Užitočné pri sledovaní videí, alebo pri fotení v režime na šírku. 31 | Pri režime na šírku dočasne neaktívne 32 | 33 | O aplikácii 34 | %s\nv%s 35 | 36 | Oneskorenie, kým sa obrazovka vypne. \n\nAktuálne nastavenie:%s 37 | Hodnota uzamknutia obrazovky 38 | 39 | Oneskorenie, kým sa obrazovka zapne. \n\nAktuálne nastavenie:%s 40 | Hodnota odomknutia obrazovky 41 | 42 | FUNGUJE IBA NA NIEKTORÝCH ZARIADENIACH. Na ostatných zariadeniach nebude funkcia ZAP/VYP fungovať správne. Skúste to. 43 | Úsporný režim 44 | 45 | Rovnaké ako hodnota zamknutia 46 | Okamžite 47 | 0.5 sek 48 | 1 sek 49 | 2 sek 50 | 3 sek 51 | 10 sek 52 | 53 | Odinštalovať aplikáciu 54 | Ste si istý, že chcete odinštalovať túto aplikáciu? 55 | 56 | 57 | Version 2.5 (2014/07/19) 59 |
    60 |
  • long awaited feature! Now you can select which apps to exclude!
  • 61 |
62 | Version 2.4.2 (2014/07/06) 63 |
    64 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 65 |
66 | Version 2.4 (2014/02/15) 67 |
    68 |
  • Remove testing unlock feature
  • 69 |
  • fix crashes on some devices
  • 70 |
71 | Version 2.3 (2014/02/14) 72 |
    73 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 74 |
  • Improvement: Add Vibrate while turning off screen.
  • 75 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 76 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 77 |
78 | Version 2.2 (2013/12/02): 79 |
    80 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 81 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 82 |
83 | Version 2.1.0 (2013/08/19): 84 |
    85 |
  • Improvement: It\'s possible to hear cover close sound now
  • 86 |
  • Add French translation: Thanks for Geoffrey Frogeye\' help
  • 87 |
88 | Version 2.0.10 (2013/08/04): 89 |
    90 |
  • Improvement: Improves sensitivity of Landscape disabling
  • 91 |
  • Add Vietnamese translation: Thanks for Hai Long Hoang\' help
  • 92 |
93 | Version 2.0.9 (2013/07/04): 94 |
    95 |
  • Issue Fix: Turning on feature, and scroll settings, it will cause turn off feature (Google\'s issue)
  • 96 |
97 | Version 2.0.8 (2013/06/30): 98 |
    99 |
  • Feature: Add Power Save Mode. ONLY Works on Some devices. If it makes screen on/off not working. Don\'t use it.
  • 100 |
  • Issue Fix: Sleeping time not working, after rebooting the device.
  • 101 |
  • Issue Fix: Auto turn on Screen (but turn off right away) should work normally on Samsung devices now. I hope so, since I don\'t have one to verify.
  • 102 |
103 | Version 2.0.7 (2013/06/20): 104 |
    105 |
  • Add partial wakelock back
  • 106 |
107 | Version 2.0.6 (2013/06/19): 108 |
    109 |
  • Reduce power consumption by removing partial wakelock
  • 110 |
111 | Version 2.0.5 (2013/06/15): 112 |
    113 |
  • Issue fix: When sleep time is up, the function is not enabled again.
  • 114 |
115 | Version 2.0.4 (2013/06/13): 116 |
    117 |
  • Issue fix: fix crash issue on android 2.x devices.
  • 118 |
119 | Version 2.0.3 (2013/06/11): 120 |
    121 |
  • Fine tuning: fine tune sensor parameter in order to save more power.
  • 122 |
123 | Version 2.0.2 (2013/06/10): 124 |
    125 |
  • Issue fix: some people may encounter notification not working issue. it\'s fixed in this version
  • 126 |
  • Restart service after upgrading app.
  • 127 |
128 | Version 2.0.1 (2013/06/08): 129 |
    130 |
  • Issue fix: if you are using Android 2.x devices, make sure you update this version, so that notification can work for you.
  • 131 |
  • Move \"Uninstall App\" button to actionbar; make room for preferences.
  • 132 |
133 | Version 2.0 (2013/06/07): 134 |
    135 |
  • Add notification: now you can toggle the feature more conveniently!
  • 136 |
137 | Version 1.9: 138 |
    139 |
  • Largely shrink the app file size by removing unwanted libs
  • 140 |
  • Add sleep time settings, to better reduce power consumption.
  • 141 |
  • Change application logo icon
  • 142 |
  • Issue fix: sometimes \"Enable while plugged\" can\'t function well.
  • 143 |
144 | Version 1.8: 145 |
    146 |
  • works after rebooting the device. You don\'t have to manually turn on the function again.
  • 147 |
  • A version changelog dialog is added. Every time a new version arrives, it\'s easier for you to know what\'s been added.
  • 148 |
  • Timeout value can be correctly updated now!
  • 149 |
150 | ]]> 151 |
152 | 153 | Nastavenia času spánku (Beta) 154 | pre zníženie spotreby.(Stále to má chybičky. Prosím nahláste mi ak sa nejaká vyskytne.) 155 | Deaktivovať počas spánku 156 | Začiatok spánku 157 | Koniec spánku 158 | 159 | Rýchlejšie prepínanie, taktiež obsahuje tlačítko pre vypnutie obrazovky. 160 | Zobraziť oznámenie 161 | Nabíjanie! AutoScreen nie je aktívny. 162 | AutoScreen je aktívny. 163 | AutoScreen nie je aktívny. 164 | 165 | 166 | https://github.com/plateaukao/PowerOff 167 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 168 | Prehrá zvuk keď sa automaticky vypne obrazovka. 169 | Prehrať zvuk 170 | 171 | 172 |
-------------------------------------------------------------------------------- /res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Extinction Auto 5 | Paramètres de l\'extinction auto 6 | Paramètres 7 | Hello world! 8 | 9 | Extinction automatique activé 10 | Extinction automatique desactivé 11 | Nécessite ce privilège pour pouvoir éteindre l\'écran 12 | Extinction automatique 13 | 14 | Paramètres de l\'extinction automatique 15 | Paramètres de l\'alimentation 16 | Avancé 17 | 18 | ne fonctionne que pendant le chargement 19 | Seulement quand branché 20 | 21 | Allume/Éteint l\'écran automatiquement 22 | Activer 23 | Désinstaller l\'application 24 | 25 | Évaluer l\'application ! 26 | Voir sur GitHub 27 | À propos 28 | Quoi de neuf 29 | 30 | Pratique pour prendre des photos ou regarder des vidéos en mode paysage. 31 | Désactiver en mode paysage 32 | 33 | À propos 34 | %s\nv%s 35 | 36 | Laps de temps avant que l\'écran se désactive. \n\nParamètre actuel:%s 37 | Temps avant désactivation 38 | 39 | Laps de temps avant que l\'écran s\'active. \n\nParamètre actuel:%s 40 | Temps avant activation 41 | 42 | Fonctionne seulement sur QUELQUES appareils. Sur les autres, cette fonction ne marchera pas correctement. Essayez par vous-même. 43 | Mode économie d\'énergie 44 | 45 | Comme la désactivation 46 | Directement 47 | 0.5 secondes 48 | 1 secondes 49 | 2 secondes 50 | 3 secondes 51 | 10 secondes 52 | 53 | Désinstaller l\'application 54 | Voulez-vous vraiment désinstaller cette application ? 55 | 56 | 57 | Version 2.5 (2014/07/19) 59 |
    60 |
  • long awaited feature! Now you can select which apps to exclude!
  • 61 |
62 | Version 2.4.2 (2014/07/06) 63 |
    64 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 65 |
66 | Version 2.4 (2014/02/15) 67 |
    68 |
  • Remove testing unlock feature
  • 69 |
  • fix crashes on some devices
  • 70 |
71 | Version 2.3 (2014/02/14) 72 |
    73 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 74 |
  • Improvement: Add Vibrate while turning off screen.
  • 75 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 76 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 77 |
78 | Version 2.2 (2013/12/02): 79 |
    80 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 81 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 82 |
83 | Version 2.1.0 (19/08/2013) : 84 |
    85 |
  • Amelioration : Joue un son lors de l\'extinction automatique de l\'écran
  • 86 |
  • Ajout d\'une traduction français. Merci de l\'aide de Geoffrey Frogeye\'
  • 87 |
88 | Version 2.0.10 (04/08/2013) : 89 |
    90 |
  • Amelioration : Ameliore la sensitivité de la désactivation en mode paysage
  • 91 |
  • Ajout d\'une traduction vietnamienne. Merci de l\'aide de Hai Long Hoang\'
  • 92 |
93 | Version 2.0.9 (04/07/2013) : 94 |
    95 |
  • Bug résolu : Activer la fonction principale et descendre dans les paramètres désactivera la fonction (bug de Google)
  • 96 |
97 | Version 2.0.8 (30/06/2013) : 98 |
    99 |
  • Fonctionnalité : Ajout du mode économie d\'énergie. Ne fonctionne que sur QUELQUES appareils. Si cette option empêche le fonctionnement de la désactivation automatique de l\'écran, désactivez-la.
  • 100 |
  • Bug résolu : Le temps de nuit ne fonctionne pas après avoir redémarré l\'appareil.
  • 101 |
  • Bug résolu : La fonction d\'activation automatique de l\'écran devrait maintenant fonctionner normalement sur les appareils Samsung.
  • 102 |
103 | Version 2.0.7 (20/06/2013) : 104 |
    105 |
  • Retour du WaveLock partiel
  • 106 |
107 | Version 2.0.6 (19/06/2013) : 108 |
    109 |
  • Consommation de batterie réduite en enlevant le WaveLock partiel
  • 110 |
111 | Version 2.0.5 (15/06/2013) : 112 |
    113 |
  • Bug résolu : La fonction n\'est pas re-activée lors de la sortie du temps de nuit.
  • 114 |
115 | Version 2.0.4 (13/06/2013) : 116 |
    117 |
  • Bug résolu : Crash sur les appareils Android 2.x
  • 118 |
119 | Version 2.0.3 (11/06/2013) : 120 |
    121 |
  • Réglage précis : Ajuste les paramètres du capteur pour économiser plus d\'énergie
  • 122 |
123 | Version 2.0.2 (10/06/2013) : 124 |
    125 |
  • Bug résolu : Certaines personnes peuvent renconstrer une notification indiquant que la fonction ne marche pas
  • 126 |
  • Redémarre le service après avoir fait la mise à jour
  • 127 |
128 | Version 2.0.1 (08/06/2013) : 129 |
    130 |
  • Bug résolu : Si vous utilisez un appareil Android 2.x, mettez à jour cette application pour que la notification fonctionne pour vous
  • 131 |
  • Le boutton \"Désinstaller l\'application\" a été déplacé vers la barrer d\'action pour faire de la place dans les préférences
  • 132 |
133 | Version 2.0 (07/06/2013) : 134 |
    135 |
  • Ajout d\'une notification : vous pouvez maintenant activer ou désactiver l\'extinction automatique de l\'écran plus commodément !
  • 136 |
137 | Version 1.9 : 138 |
    139 |
  • Grandement réduit la taille de l\'application en enlevant les bibliothèques inutilisées
  • 140 |
  • Ajout du temps de nuit, pour réduire la consommation de batterie
  • 141 |
  • Logo de l\'application changé
  • 142 |
  • Bug résolu : Parfois la fonction \"Activer quand branché\" ne fonctionne pas bien
  • 143 |
144 | Version 1.8 : 145 |
    146 |
  • Fonctionne maintenant après avoir redémarré l\'appareil. Plus besoin de réactiver la fonction manuellement.
  • 147 |
  • Un journal des modifications a été ajouté. À chaque fois qu\'une nouvelle version arrive, il est plus facile de savoir ce qui a été ajouté.
  • 148 |
  • Bug résolu : Les valeurs de laps de temps peuvent maintenant être correctement modifiées
  • 149 |
150 | ]]> 151 |
152 | 153 | Mode nuit (Beta) 154 | pour réduire l\'usage de la batterie (encore un peu buggué, reportez les bugs si vous en trouvez) 155 | Désactiver pendant la nuit 156 | Heure de démarrage du mode nuit 157 | Heure d\'arrêt du mode nuit 158 | 159 | Inclut deux boutons pour activer ou non de l\'extinction automatique et pour éteindre l\'écran 160 | Activer la notification 161 | Chargement en cours. Extinction automatique activée 162 | Extinction automatique activée 163 | Extinction automatique désactivée 164 | 165 | 166 | https://github.com/plateaukao/PowerOff 167 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 168 | Joue un son lors de l\'extinction automatique de l\'écran 169 | Écouter le son 170 | 171 | 172 |
-------------------------------------------------------------------------------- /res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AutoScreenOnOff 5 | Auto Screen Einstellungen 6 | Einstelungen 7 | Hello world! 8 | 9 | Schalte AutoScreen AN 10 | Schalte AutoScreen AUS 11 | Diese Brechtigung ist erforderlich um den Bildschirm auszuschalten 12 | Screen OnOff 13 | 14 | Auto Screen Einstellungen 15 | Energie Einstellungen 16 | Fortgeschritten 17 | 18 | Funktioniert nur während Laden. 19 | Nur beim Laden 20 | 21 | Display An/Aus automatisch 22 | Aktivieren 23 | Deinstallieren 24 | 25 | Bewerte meine App! 26 | Gehe zu GitHub 27 | Über 28 | Was gibt es Neues? 29 | 30 | Nützlich um Fotos oder Videos im Querformat aufzunehmen/ anzuschauen. 31 | Im Querformat deaktivieren 32 | 33 | Über 34 | %s\nv%s 35 | 36 | Verzögerung bevor das Display aus geht. \n\nAktuelle Einstellung:%s 37 | Display aus Timeout Wert 38 | 39 | Verzögerung bevor das Display an geht. \n\nAktuelle Einstellung:%s 40 | Display an Timeout Wert 41 | 42 | Funktioniert nur auf EINIGEN Geräten. Probiere es selbst für dich aus. 43 | Engergiesparmodus 44 | 45 | Derselbe wie Sperr Timeout Wert 46 | Sofort 47 | 0.5 s 48 | 1 s 49 | 2 s 50 | 3 s 51 | 10 s 52 | 2 mal wischen 53 | Nie 54 | 55 | Deinstalliere App 56 | Möchtest du wirklich diese App deinstallieren? 57 | 58 | 59 | Version 2.5 (2014/07/19) 61 |
    62 |
  • long awaited feature! Now you can select which apps to exclude!
  • 63 |
64 | Version 2.4.2 (2014/07/06) 65 |
    66 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 67 |
68 | Version 2.4.1 (2014/03/16) 69 |
    70 |
  • fix crash on Android 2.2, 2.4
  • 71 |
72 | Version 2.4 (2014/02/15) 73 |
    74 |
  • Remove testing unlock feature
  • 75 |
  • fix crashes on some devices
  • 76 |
77 | Version 2.3 (2014/02/14) 78 |
    79 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 80 |
  • Improvement: Add Vibrate while turning off screen.
  • 81 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 82 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 83 |
84 | Version 2.2 (2013/12/02) 85 |
    86 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 87 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 88 |
89 | Version 2.1.0 (2013/08/19): 90 |
    91 |
  • Improvement: It\'s possible to hear cover close sound now
  • 92 |
  • Add French translation: Thanks for Geoffrey Frogeye\' help
  • 93 |
94 | Version 2.0.10 (2013/08/04): 95 |
    96 |
  • Improvement: Improves sensitivity of Landscape disabling
  • 97 |
  • Add Vietnamese translation: Thanks for Hai Long Hoang\' help
  • 98 |
99 | Version 2.0.9 (2013/07/04): 100 |
    101 |
  • Issue Fix: Turning on feature, and scroll settings, it will cause turn off feature (Google\'s issue)
  • 102 |
103 | Version 2.0.8 (2013/06/30): 104 |
    105 |
  • Feature: Add Power Save Mode. ONLY Works on Some devices. If it makes screen on/off not working. Don\'t use it.
  • 106 |
  • Issue Fix: Sleeping time not working, after rebooting the device.
  • 107 |
  • Issue Fix: Auto turn on Screen (but turn off right away) should work normally on Samsung devices now. I hope so, since I don\'t have one to verify.
  • 108 |
109 | Version 2.0.7 (2013/06/20): 110 |
    111 |
  • Add partial wakelock back
  • 112 |
113 | Version 2.0.6 (2013/06/19): 114 |
    115 |
  • Reduce power consumption by removing partial wakelock
  • 116 |
117 | Version 2.0.5 (2013/06/15): 118 |
    119 |
  • Issue fix: When sleep time is up, the function is not enabled again.
  • 120 |
121 | Version 2.0.4 (2013/06/13): 122 |
    123 |
  • Issue fix: fix crash issue on android 2.x devices.
  • 124 |
125 | Version 2.0.3 (2013/06/11): 126 |
    127 |
  • Fine tuning: fine tune sensor parameter in order to save more power.
  • 128 |
129 | Version 2.0.2 (2013/06/10): 130 |
    131 |
  • Issue fix: some people may encounter notification not working issue. it\'s fixed in this version
  • 132 |
  • Restart service after upgrading app.
  • 133 |
134 | Version 2.0.1 (2013/06/08): 135 |
    136 |
  • Issue fix: if you are using Android 2.x devices, make sure you update this version, so that notification can work for you.
  • 137 |
  • Move \"Uninstall App\" button to actionbar; make room for preferences.
  • 138 |
139 | Version 2.0 (2013/06/07): 140 |
    141 |
  • Add notification: now you can toggle the feature more conveniently!
  • 142 |
143 | Version 1.9: 144 |
    145 |
  • Largely shrink the app file size by removing unwanted libs
  • 146 |
  • Add sleep time settings, to better reduce power consumption.
  • 147 |
  • Change application logo icon
  • 148 |
  • Issue fix: sometimes \"Enable while plugged\" can\'t function well.
  • 149 |
150 | Version 1.8: 151 |
    152 |
  • works after rebooting the device. You don\'t have to manually turn on the function again.
  • 153 |
  • A version changelog dialog is added. Every time a new version arrives, it\'s easier for you to know what\'s been added.
  • 154 |
  • Timeout value can be correctly updated now!
  • 155 |
156 | ]]> 157 |
158 | 159 | Ruhemodus Einstellung (BETA) 160 | Um Akku zu sparen.(Enthält Fehler; bitte schreibe mir, wenn du welche findest.) 161 | Deaktiviere während Ruhemodus 162 | Ruhemodus Start Zeit 163 | Ruhemodus End Zeit 164 | 165 | Schnelleres Umschalten;Beinhaltet auch "Display Aus" Button 166 | Zeige Benachrichtigung 167 | Am Laden! AutoScreen ist aktiviert. 168 | AutoScreen ist aktiviert. 169 | AutoScreen ist deaktiviert. 170 | 171 | 172 | https://github.com/plateaukao/PowerOff 173 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 174 | 175 | Spiele Ton beim Display ausschalten 176 | Spiele Ton während schließen 177 | Vibriere beim Display ausschalten 178 | Vibriere während schließen 179 | 180 | 181 | On/Off Bezogene Einstellungen 182 | 183 | Sende Feedback 184 | Es sind keine E-mail Programme installiert. 185 | Feedback zur AutoScreenOnOff App 186 | Paul L. Scholz 187 |
-------------------------------------------------------------------------------- /res/values-uk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AutoScreenOnOff 5 | Налаштування Auto Screen 6 | Налаштування 7 | Hello world! 8 | 9 | Включити AutoScreen 10 | Вимкнути AutoScreen 11 | Цi права потрiбнi для вимикання екрану 12 | Вкл/Вим екрану 13 | 14 | Налаштування Auto Screen 15 | Power Settings 16 | Розширені налаштування 17 | 18 | Тiльки пiд час зарядки. 19 | Тiльки коли пiдключено зарядний пристрiй 20 | 21 | Автоматично ВКЛ/ВИМ екран 22 | Включено 23 | Uninstall 24 | 25 | Оцiнiть програму! 26 | Перехiд на GitHub 27 | Про програму 28 | Що нового 29 | 30 | Корисно для фотографування и перегляду фiльмiв y ландшафтномy режимi 31 | Тимчасово вимикати у ландшафтному режимi 32 | 33 | Про програму 34 | %s\nv%s 35 | 36 | Затримка перед ВИМкненням екрану \n\nНалаштовано:%s 37 | Таймаут вимкнення 38 | 39 | Затримка перед ВКЛюченням екрану \n\nНалаштовано:%s 40 | Таймаут включення 41 | 42 | Працює не на усiх пристроях. Будь ласка, перевiрте Ваш пристрiй самi. 43 | Режим eкономiï 44 | 45 | Так само, як при вiдключеннi 46 | Негайно 47 | 0,5 сек 48 | 1 сек 49 | 2 cек 50 | 3 cек 51 | 10 cек 52 | Подвiйний свайп 53 | Нiколи 54 | 55 | Видалити програму 56 | Ви дiйсно бажаєте видалити Auto Screen OnOff? 57 | 58 | 59 | Version 2.5 (2014/07/19) 61 |
    62 |
  • long awaited feature! Now you can select which apps to exclude!
  • 63 |
64 | Version 2.4.2 (2014/07/06) 65 |
    66 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 67 |
68 | Version 2.4.1 (2014/03/16) 69 |
    70 |
  • fix crash on Android 2.2, 2.4
  • 71 |
72 | Version 2.4 (2014/02/15) 73 |
    74 |
  • Remove testing unlock feature
  • 75 |
  • fix crashes on some devices
  • 76 |
77 | Version 2.3 (2014/02/14) 78 |
    79 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 80 |
  • Improvement: Add Vibrate while turning off screen.
  • 81 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 82 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 83 |
84 | Version 2.2 (2013/12/02) 85 |
    86 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 87 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 88 |
89 | Version 2.1.0 (2013/08/19): 90 |
    91 |
  • Improvement: It\'s possible to hear cover close sound now
  • 92 |
  • Add French translation: Thanks for Geoffrey Frogeye\' help
  • 93 |
94 | Version 2.0.10 (2013/08/04): 95 |
    96 |
  • Improvement: Improves sensitivity of Landscape disabling
  • 97 |
  • Add Vietnamese translation: Thanks for Hai Long Hoang\' help
  • 98 |
99 | Version 2.0.9 (2013/07/04): 100 |
    101 |
  • Issue Fix: Turning on feature, and scroll settings, it will cause turn off feature (Google\'s issue)
  • 102 |
103 | Version 2.0.8 (2013/06/30): 104 |
    105 |
  • Feature: Add Power Save Mode. ONLY Works on Some devices. If it makes screen on/off not working. Don\'t use it.
  • 106 |
  • Issue Fix: Sleeping time not working, after rebooting the device.
  • 107 |
  • Issue Fix: Auto turn on Screen (but turn off right away) should work normally on Samsung devices now. I hope so, since I don\'t have one to verify.
  • 108 |
109 | Version 2.0.7 (2013/06/20): 110 |
    111 |
  • Add partial wakelock back
  • 112 |
113 | Version 2.0.6 (2013/06/19): 114 |
    115 |
  • Reduce power consumption by removing partial wakelock
  • 116 |
117 | Version 2.0.5 (2013/06/15): 118 |
    119 |
  • Issue fix: When sleep time is up, the function is not enabled again.
  • 120 |
121 | Version 2.0.4 (2013/06/13): 122 |
    123 |
  • Issue fix: fix crash issue on android 2.x devices.
  • 124 |
125 | Version 2.0.3 (2013/06/11): 126 |
    127 |
  • Fine tuning: fine tune sensor parameter in order to save more power.
  • 128 |
129 | Version 2.0.2 (2013/06/10): 130 |
    131 |
  • Issue fix: some people may encounter notification not working issue. it\'s fixed in this version
  • 132 |
  • Restart service after upgrading app.
  • 133 |
134 | Version 2.0.1 (2013/06/08): 135 |
    136 |
  • Issue fix: if you are using Android 2.x devices, make sure you update this version, so that notification can work for you.
  • 137 |
  • Move \"Uninstall App\" button to actionbar; make room for preferences.
  • 138 |
139 | Version 2.0 (2013/06/07): 140 |
    141 |
  • Add notification: now you can toggle the feature more conveniently!
  • 142 |
143 | Version 1.9: 144 |
    145 |
  • Largely shrink the app file size by removing unwanted libs
  • 146 |
  • Add sleep time settings, to better reduce power consumption.
  • 147 |
  • Change application logo icon
  • 148 |
  • Issue fix: sometimes \"Enable while plugged\" can\'t function well.
  • 149 |
150 | Version 1.8: 151 |
    152 |
  • works after rebooting the device. You don\'t have to manually turn on the function again.
  • 153 |
  • A version changelog dialog is added. Every time a new version arrives, it\'s easier for you to know what\'s been added.
  • 154 |
  • Timeout value can be correctly updated now!
  • 155 |
156 | ]]> 157 |
158 | 159 | Налаштування термiну сна (Beta) 160 | Зменшує використання батареï. (Ще глючить :( Зв\'яжiться, якщо знайдете помилки.) 161 | Не активна пiд час сну 162 | Початок термiну сну 163 | Кiнець термiну сну 164 | 165 | Iконка в областi повiдомлень. Також кнопка вимкнення екрану 166 | Показувати повідомлення 167 | Зарядка! AutoScreen активовано 168 | AutoScreen активовано 169 | AutoScreen деактивовано 170 | 171 | 172 | https://github.com/plateaukao/PowerOff 173 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 174 | 175 | Звук при автовимкненнi екрану 176 | Вiдтворювати звук при автовимиканнi 177 | Вибрацiя при автовимиканнi екрану 178 | Вібрувати при автовимиканнi екрану 179 | 180 | не діяти для застосунків 181 | 182 | 183 | 184 | Налаштування Вкл\Вим 185 | 186 | Вiдправити вiдгук 187 | Не знайдено поштового клієнта 188 | Вiдправити вiдгук на програму АutoScreenOnOff 189 |
190 | -------------------------------------------------------------------------------- /res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AutoScreenOnOff 5 | Настройки Auto Screen 6 | Настройки 7 | Hello world! 8 | 9 | Включить AutoScreen 10 | Отключить Turn AutoScreen 11 | Эти права нужны для отключения экрана 12 | Вкл/Откл. экрана 13 | 14 | Настройка Auto Screen 15 | Power Settings 16 | Расширенные настройки 17 | 18 | только во время зарядки. 19 | Только когда подключено зарядное устройство 20 | 21 | Автоматически ВКЛ/ВЫКЛ экран 22 | Включено 23 | Uninstall 24 | 25 | Оцените программу! 26 | Переход на GitHub 27 | О программе 28 | Что нового 29 | 30 | Полезно для фотографирования и просмотра фильмов в ландшафтном режиме. 31 | Временно отключать в ландшафтном режиме 32 | 33 | О программе 34 | %s\nv%s 35 | 36 | Задержка перед ОТКЛючением экрана. \n\nCurrent setting:%s 37 | Таймаут отключения 38 | 39 | Задержка перед ВКЛючением экрана. \n\nCurrent setting:%s 40 | Таймаут включения 41 | 42 | Работает не на всех устройствах. Пожалуйста, проверьте Ваше устройство сами. 43 | Режим экономии 44 | 45 | Так же, как и при выключении. 46 | Немедленно 47 | 0,5 сек 48 | 1 сек 49 | 2 cек 50 | 3 cек 51 | 10 cек 52 | Двойной свайп 53 | Никогда 54 | 55 | Удалить программу 56 | Вы действительно хотите удалить Auto Screen OnOff? 57 | 58 | 59 | Version 2.5 (2014/07/19) 61 |
    62 |
  • long awaited feature! Now you can select which apps to exclude!
  • 63 |
64 | Version 2.4.2 (2014/07/06) 65 |
    66 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 67 |
68 | Version 2.4.1 (2014/03/16) 69 |
    70 |
  • fix crash on Android 2.2, 2.4
  • 71 |
72 | Version 2.4 (2014/02/15) 73 |
    74 |
  • Remove testing unlock feature
  • 75 |
  • fix crashes on some devices
  • 76 |
77 | Version 2.3 (2014/02/14) 78 |
    79 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 80 |
  • Improvement: Add Vibrate while turning off screen.
  • 81 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 82 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 83 |
84 | Version 2.2 (2013/12/02) 85 |
    86 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 87 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 88 |
89 | Version 2.1.0 (2013/08/19): 90 |
    91 |
  • Improvement: It\'s possible to hear cover close sound now
  • 92 |
  • Add French translation: Thanks for Geoffrey Frogeye\' help
  • 93 |
94 | Version 2.0.10 (2013/08/04): 95 |
    96 |
  • Improvement: Improves sensitivity of Landscape disabling
  • 97 |
  • Add Vietnamese translation: Thanks for Hai Long Hoang\' help
  • 98 |
99 | Version 2.0.9 (2013/07/04): 100 |
    101 |
  • Issue Fix: Turning on feature, and scroll settings, it will cause turn off feature (Google\'s issue)
  • 102 |
103 | Version 2.0.8 (2013/06/30): 104 |
    105 |
  • Feature: Add Power Save Mode. ONLY Works on Some devices. If it makes screen on/off not working. Don\'t use it.
  • 106 |
  • Issue Fix: Sleeping time not working, after rebooting the device.
  • 107 |
  • Issue Fix: Auto turn on Screen (but turn off right away) should work normally on Samsung devices now. I hope so, since I don\'t have one to verify.
  • 108 |
109 | Version 2.0.7 (2013/06/20): 110 |
    111 |
  • Add partial wakelock back
  • 112 |
113 | Version 2.0.6 (2013/06/19): 114 |
    115 |
  • Reduce power consumption by removing partial wakelock
  • 116 |
117 | Version 2.0.5 (2013/06/15): 118 |
    119 |
  • Issue fix: When sleep time is up, the function is not enabled again.
  • 120 |
121 | Version 2.0.4 (2013/06/13): 122 |
    123 |
  • Issue fix: fix crash issue on android 2.x devices.
  • 124 |
125 | Version 2.0.3 (2013/06/11): 126 |
    127 |
  • Fine tuning: fine tune sensor parameter in order to save more power.
  • 128 |
129 | Version 2.0.2 (2013/06/10): 130 |
    131 |
  • Issue fix: some people may encounter notification not working issue. it\'s fixed in this version
  • 132 |
  • Restart service after upgrading app.
  • 133 |
134 | Version 2.0.1 (2013/06/08): 135 |
    136 |
  • Issue fix: if you are using Android 2.x devices, make sure you update this version, so that notification can work for you.
  • 137 |
  • Move \"Uninstall App\" button to actionbar; make room for preferences.
  • 138 |
139 | Version 2.0 (2013/06/07): 140 |
    141 |
  • Add notification: now you can toggle the feature more conveniently!
  • 142 |
143 | Version 1.9: 144 |
    145 |
  • Largely shrink the app file size by removing unwanted libs
  • 146 |
  • Add sleep time settings, to better reduce power consumption.
  • 147 |
  • Change application logo icon
  • 148 |
  • Issue fix: sometimes \"Enable while plugged\" can\'t function well.
  • 149 |
150 | Version 1.8: 151 |
    152 |
  • works after rebooting the device. You don\'t have to manually turn on the function again.
  • 153 |
  • A version changelog dialog is added. Every time a new version arrives, it\'s easier for you to know what\'s been added.
  • 154 |
  • Timeout value can be correctly updated now!
  • 155 |
156 | ]]> 157 |
158 | 159 | Настройки времени сна (Beta) 160 | уменьшает потребление батареи. (Ещё глючит :( Свяжитесь, если найдете ошибки.) 161 | Не активна во время сна 162 | Начало времени сна 163 | Конец времени сна 164 | 165 | Иконка в области уведомлений. Также кнопка отключения экрана 166 | Показывать уведомления 167 | Зарядка! AutoScreen активирован 168 | AutoScreen активирован. 169 | AutoScreen деактивирован. 170 | 171 | 172 | https://github.com/plateaukao/PowerOff 173 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 174 | 175 | Звук при автовыключении экрана 176 | Воспроизвродить звук при автовыключении 177 | 178 | Вибрация при автовыключении экрана 179 | Вибрировать при автовыключении экрана 180 | 181 | 182 | Настройки Вкл\Выкл 183 | 184 | Отправить отзыв 185 | Не найден почтовый клиент. 186 | Отправить отзыв на программу АutoScreenOnOff 187 |
188 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/util/CV.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.util; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.IntentFilter; 7 | import android.content.SharedPreferences; 8 | import android.os.BatteryManager; 9 | import android.os.Build; 10 | import android.preference.PreferenceManager; 11 | import android.util.Log; 12 | 13 | import java.text.ParseException; 14 | import java.text.SimpleDateFormat; 15 | import java.util.Arrays; 16 | import java.util.Calendar; 17 | import java.util.Date; 18 | 19 | public final class CV { 20 | static final boolean debug = false; 21 | 22 | public static final String TAG = "SensorMonitor"; 23 | public static final String PREF_CHARGING_ON = "prefChargingOn"; 24 | public static final String PREF_AUTO_ON = "prefAutoOn"; 25 | public static final String PREF_DISABLE_IN_LANDSCAPE= "prefDisableInLandscape"; 26 | public static final String PREF_TIMEOUT_LOCK = "prefTimeout"; 27 | public static final String PREF_TIMEOUT_UNLOCK = "prefTimeoutUnlock"; 28 | public static final String PREF_VIEWED_VERSION_CODE = "prefViewedVersionCode"; 29 | public static final String PREF_SLEEPING = "prefSleeping"; 30 | public static final String PREF_SLEEP_START = "prefSleepStart"; 31 | public static final String PREF_SLEEP_STOP = "prefSleepStop"; 32 | public static final String PREF_SHOW_NOTIFICATION = "prefShowNotification"; 33 | public static final String PREF_NO_PARTIAL_LOCK = "prefNoPartialLock"; 34 | public static final String PREF_PLAY_CLOSE_SOUND = "prefPlayCloseSound"; 35 | public static final String PREF_VIBRATE_WHILE_CLOSE = "prefVibrateWhileClose"; 36 | public static final String PREF_STRATEGY_TURNON = "prefStrategyTurnOn"; 37 | public static final String PREF_STRATEGY_TURNOFF = "prefStrategyTurnOff"; 38 | public static final String PREF_EXCLUDE_APP_NAMES = "prefExcludeAppNames"; 39 | public static final String PREF_EXCLUDE_PACKAGES = "prefExludePackages"; 40 | 41 | // 42 | public static final String SERVICEACTION = "serviceaction"; 43 | public static final int SERVICEACTION_TOGGLE = 0; 44 | public static final int SERVICEACTION_TURNON = 1; 45 | public static final int SERVICEACTION_TURNOFF = 2; 46 | public static final int SERVICEACTION_UPDATE_DISABLE_IN_LANDSCAPE = 4; 47 | public static final int SERVICEACTION_MODE_SLEEP = 5; 48 | public static final int SERVICEACTION_SCREENOFF = 6; 49 | public static final int SERVICEACTION_SHOW_NOTIFICATION = 7; 50 | public static final int SERVICEACTION_PARTIALLOCK_TOGGLE = 8; 51 | public static final int SERVICEACTION_SET_SCHEDULE = 9; 52 | public static final int SERVICEACTION_CANCEL_SCHEDULE = 10; 53 | 54 | public static String CLOSE_AFTER="close_after"; 55 | 56 | public static String SLEEP_MODE_START = "sleep_mode_start"; 57 | // 58 | // 59 | public static final String SERVICE_INTENT_ACTION = "com.danielkao.autoscreenonoff.serviceaction"; 60 | public static final String UPDATE_WIDGET_ACTION = "com.danielkao.autoscreenonoff.updatewidget"; 61 | // 62 | public static final String SERVICETYPE = "servicetype"; 63 | public static final String SERVICETYPE_CHARGING = "charging"; 64 | public static final String SERVICETYPE_SETTING = "setting"; 65 | public static final String SERVICETYPE_WIDGET = "widget"; 66 | public static final String SERVICETYPE_NOTIFICATION = "notification"; 67 | // rotation threshold 68 | public static final int ROTATION_THRESHOLD = 45; 69 | 70 | @TargetApi(Build.VERSION_CODES.GINGERBREAD) 71 | public static void logv(Object...argv){ 72 | if(!debug) 73 | return; 74 | 75 | if(argv.length == 1) 76 | Log.v(TAG, (String) argv[0]); 77 | else 78 | { 79 | Object [] slicedObj = Arrays.copyOfRange(argv, 1, argv.length); 80 | Log.v(TAG,String.format((String) argv[0], (Object[])slicedObj)); 81 | } 82 | } 83 | 84 | public static void logi(Object...argv){ 85 | if(!debug) 86 | return; 87 | 88 | if(argv.length == 1) 89 | Log.i(TAG, (String) argv[0]); 90 | else 91 | { 92 | Object [] slicedObj = Arrays.copyOfRange(argv, 1, argv.length); 93 | Log.i(TAG,String.format((String) argv[0], (Object[])slicedObj)); 94 | } 95 | } 96 | 97 | public static boolean getPrefAutoOnoff(Context context) { 98 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 99 | return sp.getBoolean(PREF_AUTO_ON, false); 100 | } 101 | 102 | public static boolean getPrefChargingOn(Context context) { 103 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 104 | boolean isPrefChargingOn = sp.getBoolean(PREF_CHARGING_ON, false); 105 | CV.logv("prefchargingon: %b", isPrefChargingOn); 106 | return isPrefChargingOn; 107 | } 108 | 109 | public static boolean getPrefDisableInLandscape(Context context) { 110 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 111 | boolean isPrefDisableInLandscape = sp.getBoolean(PREF_DISABLE_IN_LANDSCAPE, false); 112 | CV.logv("prefdisableinlandscape: %b", isPrefDisableInLandscape); 113 | return isPrefDisableInLandscape; 114 | } 115 | 116 | public static boolean getPrefSleeping(Context context) { 117 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 118 | boolean i = sp.getBoolean(PREF_SLEEPING, false); 119 | CV.logv("prefSleeping: %b", i); 120 | return i; 121 | } 122 | 123 | public static String getPrefSleepStart(Context context){ 124 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 125 | String s = sp.getString(PREF_SLEEP_START, "22:00"); 126 | CV.logv("prefSleepStart: %s", s); 127 | return s; 128 | } 129 | 130 | public static String getPrefSleepStop(Context context){ 131 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 132 | String s = sp.getString(PREF_SLEEP_STOP, "22:00"); 133 | CV.logv("prefSleepStop: %s", s); 134 | return s; 135 | } 136 | 137 | public static boolean getPrefShowNotification(Context context){ 138 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 139 | boolean b = sp.getBoolean(PREF_SHOW_NOTIFICATION, false); 140 | CV.logv("prefShowNotification: %b", b); 141 | return b; 142 | } 143 | 144 | public static boolean getPrefNoPartialLock(Context context){ 145 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 146 | boolean b = sp.getBoolean(PREF_NO_PARTIAL_LOCK, false); 147 | CV.logv("prefShowNotification: %b", b); 148 | return b; 149 | } 150 | 151 | public static boolean getPrefPlayCloseSound(Context context){ 152 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 153 | boolean b = sp.getBoolean(PREF_PLAY_CLOSE_SOUND, false); 154 | CV.logv("prefPlayCloseSound: %b", b); 155 | return b; 156 | } 157 | 158 | public static boolean getVibrateWhileClose(Context context){ 159 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 160 | boolean b = sp.getBoolean(PREF_VIBRATE_WHILE_CLOSE, false); 161 | CV.logv("prefVibrateWhileClose: %b", b); 162 | return b; 163 | } 164 | 165 | //return milliseconds 166 | public static int getPrefTimeoutLock(Context context) { 167 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 168 | int i = Integer.parseInt(sp.getString(PREF_TIMEOUT_LOCK, "0")); 169 | CV.logv("prefTimeout lock: %d", i); 170 | return i; 171 | } 172 | 173 | public static int getPrefTimeoutUnlock(Context context) { 174 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 175 | int i = Integer.parseInt(sp.getString(PREF_TIMEOUT_UNLOCK, "-1")); 176 | CV.logv("prefTimeout unlock: %d", i); 177 | 178 | // if the value is -1, means user want it to be the same as lock timeout value 179 | if(i==-1) 180 | { 181 | i = getPrefTimeoutLock(context); 182 | } 183 | return i; 184 | } 185 | 186 | public static String getExcludeAppNameList(Context context) { 187 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 188 | String names = sp.getString(PREF_EXCLUDE_APP_NAMES, ""); 189 | CV.logv("prefExcludeAppNames: %s", names); 190 | 191 | return names; 192 | } 193 | 194 | public static void setExcludeAppNameList(Context context, String names) { 195 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 196 | SharedPreferences.Editor editor = sp.edit(); 197 | editor.putString(PREF_EXCLUDE_APP_NAMES, names); 198 | editor.commit(); 199 | } 200 | 201 | public static String getExcludeAppPackageNames(Context context) { 202 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 203 | String packagenames = sp.getString(PREF_EXCLUDE_PACKAGES, null); 204 | return packagenames; 205 | } 206 | 207 | public static boolean isPlugged(Context context){ 208 | Intent intentBat = context.getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); 209 | return (intentBat.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) > 0); 210 | } 211 | 212 | public static boolean isInSleepTime(Context context){ 213 | String pattern = "HH:mm"; 214 | SimpleDateFormat sdf = new SimpleDateFormat(pattern); 215 | try{ 216 | Date timeStart = sdf.parse(getPrefSleepStart(context)); 217 | Date timeStop = sdf.parse(getPrefSleepStop(context)); 218 | Calendar now = Calendar.getInstance(); 219 | Date timeNow = sdf.parse(now.get(Calendar.HOUR_OF_DAY)+":"+now.get(Calendar.MINUTE)); 220 | 221 | // start < stop 222 | if(timeStart.compareTo(timeStop)<0){ 223 | if(timeStart.before(timeNow) && timeStop.after(timeNow)) 224 | return true; 225 | else 226 | return false; 227 | 228 | }else{ 229 | if(timeStop.before(timeNow) && timeStart.after(timeNow)) 230 | return false; 231 | else 232 | return true; 233 | } 234 | 235 | } catch (ParseException e){ 236 | e.printStackTrace(); 237 | } 238 | 239 | return false; 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AutoScreenOnOff 5 | Settings 6 | Settings 7 | Hello world! 8 | 9 | Turn AutoScreen ON 10 | Turn AutoScreen OFF 11 | Need this privilege to turn off the screen 12 | Screen OnOff 13 | 14 | Auto Screen Settings 15 | Power Settings 16 | Advanced 17 | 18 | only works during charging. 19 | Only when plugged 20 | 21 | Screen On/Off automatically 22 | Enable 23 | Uninstall 24 | 25 | Rank my App! 26 | goto GitHub 27 | About 28 | What\'s New 29 | 30 | Useful for taking photos or watching movies in landscape. 31 | Temporarily Disable in Landscape 32 | 33 | About 34 | %s\nv%s 35 | 36 | Delay how long before Screen Off take effects. \n\nCurrent setting:%s 37 | Screen Off Timeout Value 38 | 39 | Delay how long before Screen On take effects. \n\nCurrent setting:%s 40 | Screen On Timeout Value 41 | 42 | ONLY WORKS on SOME devices. On other devices, the on/off function will not work well. Try by yourself. 43 | Power Save Mode 44 | 45 | Same as Lock Timeout Value 46 | Right Away 47 | 0.5 sec 48 | 1 sec 49 | 2 sec 50 | 3 sec 51 | 10 sec 52 | Swipe Twice 53 | Never 54 | 55 | 56 | @string/timeout_0 57 | @string/timeout_05 58 | @string/timeout_1 59 | @string/timeout_2 60 | @string/timeout_3 61 | @string/timeout_10 62 | @string/timeout_4 63 | @string/timeout_5 64 | 65 | 66 | 67 | 68 | 0 69 | 500 70 | 1000 71 | 2000 72 | 3000 73 | 10000 74 | 75 | 2 76 | 77 | 10 78 | 79 | 80 | 81 | @string/timeout_same 82 | @string/timeout_0 83 | @string/timeout_05 84 | @string/timeout_1 85 | @string/timeout_2 86 | @string/timeout_3 87 | @string/timeout_10 88 | @string/timeout_4 89 | @string/timeout_5 90 | 91 | 92 | 93 | 94 | -1 95 | 0 96 | 500 97 | 1000 98 | 2000 99 | 3000 100 | 10000 101 | 102 | 2 103 | 104 | 10 105 | 106 | 107 | Uninstall App 108 | Do you really want to uninstall this app? 109 | 110 | 111 | Version 2.7 (2015/02/06) 113 |
    114 |
  • disable functions while in call
  • 115 |
  • fix exclude-app list not working in Android 5
  • 116 |
  • try to fix sleep timer issue
  • 117 |
118 | ]]> 119 |
120 | 121 | Version 2.6 (2014/07/22) 123 |
    124 |
  • Another long awaited feature! Now you can add a Screen Off widget on your home!
  • 125 |
126 | ]]> 127 |
128 | 129 | Version 2.5 (2014/07/19) 131 |
    132 |
  • long awaited feature! Now you can select which apps to exclude!
  • 133 |
134 | Version 2.4.2 (2014/07/06) 135 |
    136 |
  • add German, Russian, Ukranian translations, Thanks to Paul L. Scholz, and Andrew
  • 137 |
138 | Version 2.4.1 (2014/03/16) 139 |
    140 |
  • fix crash on Android 2.2, 2.4
  • 141 |
142 | Version 2.4 (2014/02/15) 143 |
    144 |
  • Remove testing unlock feature
  • 145 |
  • fix crashes on some devices
  • 146 |
147 | Version 2.3 (2014/02/14) 148 |
    149 |
  • Add Dutch translation: Thanks for Xander Stone\'s help
  • 150 |
  • Improvement: Add Vibrate while turning off screen.
  • 151 |
  • Improvement: make Uninstall action more visible on Actionbar. Don\'t mail me how to uninstall anymore...
  • 152 |
  • Improvement: make time picker 24 hour format. Should be more useful.
  • 153 |
154 | Version 2.2 (2013/12/02) 155 |
    156 |
  • Improvement: Add swipe feature. You can set up in Timeout settings.
  • 157 |
  • Improvement: Add Disable TurnOn or TurnOff feature. in Timeout settings too.
  • 158 |
159 | Version 2.1.0 (2013/08/19): 160 |
    161 |
  • Improvement: It\'s possible to hear cover close sound now
  • 162 |
  • Add French translation: Thanks for Geoffrey Frogeye\' help
  • 163 |
164 | Version 2.0.10 (2013/08/04): 165 |
    166 |
  • Improvement: Improves sensitivity of Landscape disabling
  • 167 |
  • Add Vietnamese translation: Thanks for Hai Long Hoang\' help
  • 168 |
169 | Version 2.0.9 (2013/07/04): 170 |
    171 |
  • Issue Fix: Turning on feature, and scroll settings, it will cause turn off feature (Google\'s issue)
  • 172 |
173 | Version 2.0.8 (2013/06/30): 174 |
    175 |
  • Feature: Add Power Save Mode. ONLY Works on Some devices. If it makes screen on/off not working. Don\'t use it.
  • 176 |
  • Issue Fix: Sleeping time not working, after rebooting the device.
  • 177 |
  • Issue Fix: Auto turn on Screen (but turn off right away) should work normally on Samsung devices now. I hope so, since I don\'t have one to verify.
  • 178 |
179 | Version 2.0.7 (2013/06/20): 180 |
    181 |
  • Add partial wakelock back
  • 182 |
183 | Version 2.0.6 (2013/06/19): 184 |
    185 |
  • Reduce power consumption by removing partial wakelock
  • 186 |
187 | Version 2.0.5 (2013/06/15): 188 |
    189 |
  • Issue fix: When sleep time is up, the function is not enabled again.
  • 190 |
191 | Version 2.0.4 (2013/06/13): 192 |
    193 |
  • Issue fix: fix crash issue on android 2.x devices.
  • 194 |
195 | Version 2.0.3 (2013/06/11): 196 |
    197 |
  • Fine tuning: fine tune sensor parameter in order to save more power.
  • 198 |
199 | Version 2.0.2 (2013/06/10): 200 |
    201 |
  • Issue fix: some people may encounter notification not working issue. it\'s fixed in this version
  • 202 |
  • Restart service after upgrading app.
  • 203 |
204 | Version 2.0.1 (2013/06/08): 205 |
    206 |
  • Issue fix: if you are using Android 2.x devices, make sure you update this version, so that notification can work for you.
  • 207 |
  • Move \"Uninstall App\" button to actionbar; make room for preferences.
  • 208 |
209 | Version 2.0 (2013/06/07): 210 |
    211 |
  • Add notification: now you can toggle the feature more conveniently!
  • 212 |
213 | Version 1.9: 214 |
    215 |
  • Largely shrink the app file size by removing unwanted libs
  • 216 |
  • Add sleep time settings, to better reduce power consumption.
  • 217 |
  • Change application logo icon
  • 218 |
  • Issue fix: sometimes \"Enable while plugged\" can\'t function well.
  • 219 |
220 | Version 1.8: 221 |
    222 |
  • works after rebooting the device. You don\'t have to manually turn on the function again.
  • 223 |
  • A version changelog dialog is added. Every time a new version arrives, it\'s easier for you to know what\'s been added.
  • 224 |
  • Timeout value can be correctly updated now!
  • 225 |
226 | ]]> 227 |
228 | 229 | Sleep Time Setting (Beta) 230 | to save power consumption.(Still buggy. report to me if you find bugs.) 231 | Disable while Sleep 232 | Sleep Start Time 233 | Sleep End Time 234 | 235 | Faster toggle;also including screen off button 236 | Show Notification 237 | Charging! AutoScreen is enabled. 238 | AutoScreen is enabled. 239 | AutoScreen is disabled. 240 | 241 | 242 | https://github.com/plateaukao/PowerOff 243 | https://play.google.com/store/apps/details?id=com.danielkao.autoscreenonoff 244 | 245 | Play sound while auto turning off screen 246 | Play Sound While Close 247 | Vibrate while auto turning off screen 248 | Vibrate While Close 249 | 250 | which apps to exclude 251 | 252 | 253 | 254 | On/Off Related Settings 255 | 256 | Send feedback 257 | There are no email clients installed. 258 | Feedback to autoscreenonoff app 259 |
260 | -------------------------------------------------------------------------------- /src/com/danielkao/autoscreenonoff/ui/AutoScreenOnOffPreferenceActivity.java: -------------------------------------------------------------------------------- 1 | package com.danielkao.autoscreenonoff.ui; 2 | 3 | import android.app.Activity; 4 | import android.app.AlarmManager; 5 | import android.app.AlertDialog; 6 | import android.app.Dialog; 7 | import android.app.admin.DevicePolicyManager; 8 | import android.appwidget.AppWidgetManager; 9 | import android.content.*; 10 | import android.content.pm.PackageInfo; 11 | import android.content.pm.PackageManager; 12 | import android.net.Uri; 13 | import android.os.Build; 14 | import android.os.Bundle; 15 | import android.preference.ListPreference; 16 | import android.preference.Preference; 17 | import android.preference.PreferenceActivity; 18 | import android.preference.PreferenceManager; 19 | import android.view.*; 20 | import android.webkit.WebView; 21 | import android.widget.Toast; 22 | import com.danielkao.autoscreenonoff.R; 23 | import com.danielkao.autoscreenonoff.receiver.TurnOffReceiver; 24 | import com.danielkao.autoscreenonoff.service.SensorMonitorService; 25 | import com.danielkao.autoscreenonoff.util.CV; 26 | import com.danielkao.autoscreenonoff.util.EnvironmentInfoUtils; 27 | 28 | /** 29 | * Created by plateau on 2013/05/20. 30 | */ 31 | public class AutoScreenOnOffPreferenceActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener{ 32 | private static String CONFIGURE_ACTION="android.appwidget.action.APPWIDGET_CONFIGURE"; 33 | 34 | private static final int REQUEST_CODE_DISABLE_ADMIN = 1; 35 | 36 | private DevicePolicyManager deviceManager; 37 | private ComponentName mDeviceAdmin; 38 | 39 | //service 40 | private SensorMonitorService sensorService; 41 | 42 | // ad service 43 | /* 44 | private static final String MY_AD_UNIT_ID = "a1519f30be4a645"; 45 | private AdView adView; 46 | */ 47 | // --- 48 | 49 | // schedule 50 | AlarmManager am; 51 | private AlarmManager getAlarmManager(){ 52 | if(am==null) 53 | { 54 | am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); 55 | } 56 | return am; 57 | } 58 | 59 | @Override 60 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 61 | super.onActivityResult(requestCode, resultCode, data); 62 | 63 | if (REQUEST_CODE_DISABLE_ADMIN == requestCode) { 64 | if (resultCode == Activity.RESULT_OK) { 65 | // Has become the device administrator. 66 | } else { 67 | //Canceled or failed: turn off Enabler 68 | } 69 | } 70 | } 71 | 72 | @Override 73 | protected void onStart() { 74 | super.onStart(); 75 | // for receiving pref change callbacks 76 | PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); 77 | updatePrefState(); 78 | } 79 | 80 | @Override 81 | public void onCreate(Bundle savedInstanceState) { 82 | super.onCreate(savedInstanceState); 83 | 84 | addPreferencesFromResource(R.xml.widget_configure); 85 | setContentView(R.layout.activity_settings); 86 | 87 | showChangelogDialogCheck(); 88 | } 89 | 90 | @Override 91 | protected void onStop() { 92 | super.onStop(); 93 | 94 | PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this); 95 | 96 | } 97 | 98 | @Override 99 | public void onDestroy() { 100 | /* 101 | if (adView != null) { 102 | adView.destroy(); 103 | } 104 | */ 105 | super.onDestroy(); 106 | } 107 | 108 | 109 | // 110 | @Override 111 | public boolean onCreateOptionsMenu(Menu menu) { 112 | getMenuInflater().inflate(R.menu.menu,menu); 113 | return true; 114 | } 115 | 116 | @Override 117 | public boolean onOptionsItemSelected(MenuItem item) { 118 | switch(item.getItemId()){ 119 | case R.id.menu_uninstall_app: 120 | { 121 | uninstallApp(null); 122 | return true; 123 | } 124 | case R.id.menu_changelog: 125 | { 126 | showChangelogDialog(); 127 | return true; 128 | } 129 | case R.id.menu_playstore_url: 130 | { 131 | String url = getString(R.string.playstore_url); 132 | Intent i = new Intent(Intent.ACTION_VIEW); 133 | i.setData(Uri.parse(url)); 134 | startActivity(i); 135 | return true; 136 | } 137 | case R.id.menu_code_url: 138 | { 139 | String url = getString(R.string.author_url); 140 | Intent i = new Intent(Intent.ACTION_VIEW); 141 | i.setData(Uri.parse(url)); 142 | startActivity(i); 143 | return true; 144 | } 145 | case R.id.menu_send_feedback: 146 | { 147 | Intent i = new Intent(Intent.ACTION_SEND); 148 | i.setType("message/rfc822"); 149 | i.putExtra(Intent.EXTRA_EMAIL , new String[]{"leinadkao@gmail.com"}); 150 | i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject)); 151 | i.putExtra(Intent.EXTRA_TEXT , "\n\n\n- - - - - - -\n" + EnvironmentInfoUtils.getApplicationInfo(this)); 152 | try { 153 | startActivity(Intent.createChooser(i, "Send mail...")); 154 | } catch (android.content.ActivityNotFoundException ex) { 155 | Toast.makeText(this, getString(R.string.no_mail_client_warning), Toast.LENGTH_SHORT).show(); 156 | } 157 | 158 | return true; 159 | } 160 | case R.id.menu_about: 161 | { 162 | String appName = getString(R.string.app_name); 163 | String version=""; 164 | try { 165 | version = getPackageManager().getPackageInfo(getPackageName(),0).versionName; 166 | } catch (PackageManager.NameNotFoundException e) { 167 | e.printStackTrace(); 168 | } 169 | String about = String.format(getString(R.string.dialog_about_message), appName, version); 170 | 171 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 172 | Dialog d = builder.setMessage(about) 173 | .setTitle(R.string.dialog_about_title) 174 | .create(); 175 | d.show(); 176 | 177 | return true; 178 | 179 | } 180 | default: 181 | return super.onOptionsItemSelected(item); 182 | } 183 | } 184 | // 185 | 186 | @Override 187 | public boolean onKeyDown(int keyCode, KeyEvent event) { 188 | if (keyCode==KeyEvent.KEYCODE_BACK && 189 | Integer.parseInt(Build.VERSION.SDK)<5) { 190 | onBackPressed(); 191 | } 192 | 193 | return(super.onKeyDown(keyCode, event)); 194 | } 195 | 196 | @Override 197 | public void onBackPressed() { 198 | if (CONFIGURE_ACTION.equals(getIntent().getAction())) { 199 | Intent intent=getIntent(); 200 | Bundle extras=intent.getExtras(); 201 | 202 | if (extras!=null) { 203 | int id=extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); 204 | 205 | Intent result=new Intent(); 206 | 207 | result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 208 | id); 209 | setResult(RESULT_OK, result); 210 | } 211 | } 212 | 213 | super.onBackPressed(); 214 | } 215 | 216 | private boolean isActiveAdmin() { 217 | return deviceManager.isAdminActive(mDeviceAdmin); 218 | } 219 | 220 | /** 221 | * uninstall button clicked or from menu item 222 | * @param view indicate which button is pressed 223 | */ 224 | public void uninstallApp(View view){ 225 | new AlertDialog.Builder(this) 226 | .setTitle(getString(R.string.dlg_uninstall_title)) 227 | .setMessage(getString(R.string.dlg_uninstall_message)) 228 | .setIcon(android.R.drawable.ic_menu_delete) 229 | .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { 230 | 231 | public void onClick(DialogInterface dialog, int whichButton) { 232 | deviceManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); 233 | mDeviceAdmin = new ComponentName(AutoScreenOnOffPreferenceActivity.this, TurnOffReceiver.class); 234 | 235 | // handle activeAdmin previlige 236 | if(isActiveAdmin()) { 237 | deviceManager.removeActiveAdmin(mDeviceAdmin); 238 | } 239 | Uri packageUri = Uri.parse("package:com.danielkao.autoscreenonoff"); 240 | Intent uninstallIntent = 241 | new Intent(Intent.ACTION_DELETE, packageUri); 242 | startActivity(uninstallIntent); 243 | }}) 244 | .setNegativeButton(android.R.string.no, null).show(); 245 | 246 | } 247 | 248 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key) 249 | { 250 | // update state of pref disable in landscape 251 | updatePrefState(); 252 | 253 | if(key.equals(CV.PREF_AUTO_ON)){ 254 | if(CV.getPrefAutoOnoff(this)==false) 255 | cancelSchedule(); 256 | else{ 257 | if(CV.getPrefSleeping(this)){ 258 | setSchedule(); 259 | } 260 | } 261 | 262 | // send intent to service 263 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 264 | i.putExtra(CV.SERVICEACTION, 265 | CV.SERVICEACTION_TOGGLE); 266 | i.putExtra(CV.SERVICETYPE, 267 | CV.SERVICETYPE_SETTING); 268 | startService(i); 269 | } 270 | else if(key.equals(CV.PREF_CHARGING_ON)){ 271 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 272 | i.putExtra(CV.SERVICEACTION, 273 | (sharedPreferences.getBoolean(key,false)) 274 | ? CV.SERVICEACTION_TURNON 275 | : CV.SERVICEACTION_TURNOFF); 276 | startService(i); 277 | } 278 | else if(key.equals(CV.PREF_SHOW_NOTIFICATION)){ 279 | // if it's on mode, then should notify service to enable onOrientationListener 280 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 281 | i.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_SHOW_NOTIFICATION); 282 | startService(i); 283 | } 284 | //notify service when Pref of temp disable in land is changed. 285 | else if(key.equals(CV.PREF_DISABLE_IN_LANDSCAPE)){ 286 | // if it's on mode, then should notify service to enable onOrientationListener 287 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 288 | i.putExtra(CV.SERVICEACTION, CV.SERVICEACTION_UPDATE_DISABLE_IN_LANDSCAPE); 289 | startService(i); 290 | }else if(key.equals(CV.PREF_TIMEOUT_LOCK)){ 291 | // for updating list preference summary 292 | ListPreference lp = (ListPreference) findPreference(CV.PREF_TIMEOUT_LOCK); 293 | String str = getString(R.string.pref_summary_timeout_lock); 294 | lp.setSummary(String.format(str,lp.getEntry())); 295 | //lp.setSummary(str); 296 | }else if(key.equals(CV.PREF_TIMEOUT_UNLOCK)){ 297 | // for updating list preference summary 298 | ListPreference lp = (ListPreference) findPreference(CV.PREF_TIMEOUT_UNLOCK); 299 | String str = getString(R.string.pref_summary_timeout_unlock); 300 | lp.setSummary(String.format(str,lp.getEntry())); 301 | }else if(key.equals(CV.PREF_SLEEPING)){ 302 | // not turned on: just igonre the change 303 | if(CV.getPrefAutoOnoff(this)==false) 304 | return; 305 | 306 | if(CV.getPrefSleeping(this)){ 307 | // on:register the alarmmanager 308 | CV.logv("set schedule"); 309 | setSchedule(); 310 | }else{ 311 | // off: cancel alarmmanager 312 | CV.logv("cancel schedule"); 313 | cancelSchedule(); 314 | 315 | // if autoOn is on, should turn it on again 316 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 317 | i.putExtra(CV.SERVICEACTION, 318 | CV.SERVICEACTION_TOGGLE); 319 | i.putExtra(CV.SERVICETYPE, 320 | CV.SERVICETYPE_SETTING); 321 | startService(i); 322 | } 323 | 324 | 325 | }else if(key.equals(CV.PREF_SLEEP_START)||key.equals(CV.PREF_SLEEP_STOP)){ 326 | // re-register alarm manager 327 | CV.logv("isInSleepTime:%b",CV.isInSleepTime(this)); 328 | if(CV.getPrefSleeping(this)){ 329 | setSchedule(); 330 | } 331 | 332 | }else if(key.equals(CV.PREF_NO_PARTIAL_LOCK)){ 333 | CV.logv("change whether to use partial lock"); 334 | 335 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 336 | i.putExtra(CV.SERVICEACTION, 337 | CV.SERVICEACTION_PARTIALLOCK_TOGGLE); 338 | startService(i); 339 | } 340 | } 341 | 342 | // 343 | private void setSchedule() { 344 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 345 | i.putExtra(CV.SERVICEACTION, 346 | CV.SERVICEACTION_SET_SCHEDULE); 347 | startService(i); 348 | } 349 | 350 | private void cancelSchedule() { 351 | Intent i = new Intent(CV.SERVICE_INTENT_ACTION); 352 | i.putExtra(CV.SERVICEACTION, 353 | CV.SERVICEACTION_CANCEL_SCHEDULE); 354 | startService(i); 355 | } 356 | // 357 | 358 | // when auto on is turned on; user can't set charging mode 359 | // only when auto on is turned on, use can set landscape mode 360 | private void updatePrefState(){ 361 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 362 | Preference spCharging, spAuto; 363 | spCharging = findPreference(CV.PREF_CHARGING_ON); 364 | spAuto = findPreference(CV.PREF_AUTO_ON); 365 | 366 | 367 | if(sp.getBoolean(CV.PREF_AUTO_ON, false)){ 368 | spAuto.setEnabled(false); 369 | spCharging.setEnabled(false); 370 | }else{ 371 | spCharging.setEnabled(true); 372 | } 373 | 374 | if(sp.getBoolean(CV.PREF_CHARGING_ON, false)){ 375 | spCharging.setEnabled(true); 376 | spAuto.setEnabled(false); 377 | }else{ 378 | spAuto.setEnabled(true); 379 | } 380 | } 381 | 382 | // 383 | private void showChangelogDialogCheck(){ 384 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 385 | int currentVersionCode = 0; 386 | int viewedVersionCode = sp.getInt(CV.PREF_VIEWED_VERSION_CODE,0); 387 | 388 | try { 389 | PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); 390 | currentVersionCode = pi.versionCode; 391 | } catch (Exception e) {e.printStackTrace();} 392 | 393 | if (currentVersionCode > viewedVersionCode) { 394 | showChangelogDialog(); 395 | 396 | SharedPreferences.Editor editor = sp.edit(); 397 | editor.putInt(CV.PREF_VIEWED_VERSION_CODE, currentVersionCode); 398 | editor.commit(); 399 | } 400 | } 401 | 402 | private void showChangelogDialog(){ 403 | //load some kind of a view 404 | LayoutInflater li = LayoutInflater.from(this); 405 | View view = li.inflate(R.layout.changelogdlg, null); 406 | WebView wv = (WebView) view.findViewById(R.id.wv_changelog); 407 | String changelogs = getString(R.string.changelog_27) 408 | + getString(R.string.changelog_26) 409 | + getString(R.string.old_changelog_html); 410 | wv.loadData(changelogs,"text/html; charset=UTF-8", null); 411 | 412 | new AlertDialog.Builder(this) 413 | .setTitle(getString(R.string.title_changelog)) 414 | .setIcon(android.R.drawable.ic_menu_info_details) 415 | .setView(view) 416 | .setNegativeButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { 417 | public void onClick(DialogInterface dialog, int whichButton) { 418 | // 419 | } 420 | }).show(); 421 | } 422 | // 423 | } --------------------------------------------------------------------------------