Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Taskbar: Commit

packages/apps/Taskbar


Commit MetaInfo

Revisiond78f738346ebcdad8172a054ecc991834de08f01 (tree)
Time2017-10-10 09:27:40
AuthorBraden Farmer <farmerbb@gmai...>
CommiterBraden Farmer

Log Message

Taskbar 3.7.1 (release 4)

Use PowerManager.isInteractive() to determine if screen is on or off

Change Summary

Incremental Difference

--- a/app/build.gradle
+++ b/app/build.gradle
@@ -34,7 +34,7 @@ android {
3434 minSdkVersion 21
3535 targetSdkVersion 26
3636
37- versionCode 169
37+ versionCode 170
3838 versionName "3.7.1"
3939
4040 resConfigs "en", "ja", "ru", "de"
--- a/app/src/main/java/com/farmerbb/taskbar/service/TaskbarService.java
+++ b/app/src/main/java/com/farmerbb/taskbar/service/TaskbarService.java
@@ -43,6 +43,7 @@ import android.graphics.Typeface;
4343 import android.os.Build;
4444 import android.os.Handler;
4545 import android.os.IBinder;
46+import android.os.PowerManager;
4647 import android.os.SystemClock;
4748 import android.os.UserHandle;
4849 import android.os.UserManager;
@@ -113,7 +114,6 @@ public class TaskbarService extends Service {
113114 private boolean taskbarHiddenTemporarily = false;
114115 private boolean isRefreshingRecents = false;
115116 private boolean isFirstStart = true;
116- private boolean isScreenOff = false;
117117
118118 private boolean startThread2 = false;
119119 private boolean stopThread2 = false;
@@ -183,20 +183,6 @@ public class TaskbarService extends Service {
183183 }
184184 };
185185
186- private BroadcastReceiver screenOffReceiver = new BroadcastReceiver() {
187- @Override
188- public void onReceive(Context context, Intent intent) {
189- isScreenOff = true;
190- }
191- };
192-
193- private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() {
194- @Override
195- public void onReceive(Context context, Intent intent) {
196- isScreenOff = false;
197- }
198- };
199-
200186 @Override
201187 public IBinder onBind(Intent intent) {
202188 return null;
@@ -539,19 +525,13 @@ public class TaskbarService extends Service {
539525 lbm.unregisterReceiver(startMenuAppearReceiver);
540526 lbm.unregisterReceiver(startMenuDisappearReceiver);
541527
542- safelyUnregisterReceiver(screenOffReceiver);
543- safelyUnregisterReceiver(screenOnReceiver);
544-
545528 lbm.registerReceiver(showReceiver, new IntentFilter("com.farmerbb.taskbar.SHOW_TASKBAR"));
546529 lbm.registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_TASKBAR"));
547530 lbm.registerReceiver(tempShowReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_SHOW_TASKBAR"));
548531 lbm.registerReceiver(tempHideReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_HIDE_TASKBAR"));
549532 lbm.registerReceiver(startMenuAppearReceiver, new IntentFilter("com.farmerbb.taskbar.START_MENU_APPEARING"));
550533 lbm.registerReceiver(startMenuDisappearReceiver, new IntentFilter("com.farmerbb.taskbar.START_MENU_DISAPPEARING"));
551-
552- registerReceiver(screenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
553- registerReceiver(screenOnReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
554-
534+
555535 startRefreshingRecents();
556536
557537 windowManager.addView(layout, params);
@@ -611,7 +591,7 @@ public class TaskbarService extends Service {
611591 @SuppressWarnings("Convert2streamapi")
612592 @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
613593 private void updateRecentApps(final boolean firstRefresh) {
614- if(isScreenOff) return;
594+ if(isScreenOff()) return;
615595
616596 SharedPreferences pref = U.getSharedPreferences(this);
617597 final PackageManager pm = getPackageManager();
@@ -1072,7 +1052,7 @@ public class TaskbarService extends Service {
10721052 }
10731053
10741054 private boolean checkPositionChange() {
1075- if(!isScreenOff && layout != null) {
1055+ if(!isScreenOff() && layout != null) {
10761056 int[] location = new int[2];
10771057 layout.getLocationOnScreen(location);
10781058
@@ -1135,9 +1115,6 @@ public class TaskbarService extends Service {
11351115 lbm.unregisterReceiver(startMenuAppearReceiver);
11361116 lbm.unregisterReceiver(startMenuDisappearReceiver);
11371117
1138- safelyUnregisterReceiver(screenOffReceiver);
1139- safelyUnregisterReceiver(screenOnReceiver);
1140-
11411118 isFirstStart = true;
11421119 }
11431120
@@ -1389,10 +1366,9 @@ public class TaskbarService extends Service {
13891366 List<ResolveInfo> ris = getPackageManager().queryIntentActivities(intentToResolve, 0);
13901367 return ris != null && ris.size() > 0;
13911368 }
1392-
1393- private void safelyUnregisterReceiver(BroadcastReceiver receiver) {
1394- try {
1395- unregisterReceiver(receiver);
1396- } catch (IllegalArgumentException e) { /* Gracefully fail */ }
1369+
1370+ private boolean isScreenOff() {
1371+ PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
1372+ return !pm.isInteractive();
13971373 }
13981374 }
Show on old repository browser