OSDN Git Service

Add running app indicators to recent apps list
authorBraden Farmer <farmerbb@gmail.com>
Fri, 15 Mar 2019 01:57:34 +0000 (19:57 -0600)
committerBraden Farmer <farmerbb@gmail.com>
Fri, 15 Mar 2019 01:58:42 +0000 (19:58 -0600)
app/build.gradle
app/src/main/java/com/farmerbb/taskbar/service/TaskbarService.java
app/src/main/java/com/farmerbb/taskbar/util/U.java
app/src/main/res/drawable/running_app_indicator.xml [new file with mode: 0644]
app/src/main/res/layout/icon.xml

index 1fba200..0f2f90a 100644 (file)
@@ -91,7 +91,8 @@ dependencies {
     implementation "com.android.support:design:${SUPPORT_LIBRARY_VERSION}"
     //noinspection GradleDependency
     implementation 'com.mikepenz:iconics-core:3.0.4'
-    implementation 'com.mikepenz:foundation-icons-typeface:3.0.0.5'
+    //noinspection GradleDependency
+    implementation 'com.mikepenz:foundation-icons-typeface:3.0.0.4'
     implementation 'moe.banana:toast-compat:1.0.5'
     implementation group:'com.twofortyfouram', name:'android-plugin-api-for-locale', version:'[1.0.2,2.0['
 }
index 44a72b1..72e7a80 100644 (file)
@@ -730,7 +730,7 @@ public class TaskbarService extends Service {
                     Collections.reverse(usageStatsList6);
                 }
 
-                // Generate the AppEntries for TaskbarAdapter
+                // Generate the AppEntries for the recent apps list
                 int number = usageStatsList6.size() == maxNumOfEntries
                         ? usageStatsList6.size() - realNumOfPinnedApps
                         : usageStatsList6.size();
@@ -743,6 +743,7 @@ public class TaskbarService extends Service {
                 for(int i = 0; i < number; i++) {
                     for(UserHandle handle : userHandles) {
                         String packageName = usageStatsList6.get(i).getPackageName();
+                        long lastTimeUsed = usageStatsList6.get(i).getLastTimeUsed();
                         List<LauncherActivityInfo> list = launcherApps.getActivityList(packageName, handle);
                         if(!list.isEmpty()) {
                             // Google App workaround
@@ -769,6 +770,7 @@ public class TaskbarService extends Service {
                             );
 
                             newEntry.setUserId(userManager.getSerialNumberForUser(handle));
+                            newEntry.setLastTimeUsed(lastTimeUsed);
                             entries.add(newEntry);
 
                             break;
@@ -823,6 +825,7 @@ public class TaskbarService extends Service {
                         launcherAppCachePos++;
                         LauncherActivityInfo appInfo = launcherAppCache.get(launcherAppCachePos);
                         String packageName = entries.get(i).getPackageName();
+                        long lastTimeUsed = entries.get(i).getLastTimeUsed();
 
                         entries.remove(i);
 
@@ -834,6 +837,7 @@ public class TaskbarService extends Service {
                                 false);
 
                         newEntry.setUserId(userManager.getSerialNumberForUser(appInfo.getUser()));
+                        newEntry.setLastTimeUsed(lastTimeUsed);
                         entries.add(i, newEntry);
                     }
                 }
@@ -1199,7 +1203,15 @@ public class TaskbarService extends Service {
         }
 
         FrameLayout layout = convertView.findViewById(R.id.entry);
-        layout.setOnClickListener(view -> U.launchApp(this, entry.getPackageName(), entry.getComponentName(), entry.getUserId(this), null, true, false));
+        layout.setOnClickListener(view -> U.launchApp(
+                this,
+                entry.getPackageName(),
+                entry.getComponentName(),
+                entry.getUserId(this),
+                null,
+                true,
+                false
+        ));
 
         layout.setOnLongClickListener(view -> {
             int[] location = new int[2];
@@ -1247,6 +1259,15 @@ public class TaskbarService extends Service {
             });
         }
 
+        if(runningAppsOnly) {
+            ImageView runningAppIndicator = convertView.findViewById(R.id.running_app_indicator);
+            if(entry.getLastTimeUsed() > 0) {
+                runningAppIndicator.setVisibility(View.VISIBLE);
+                runningAppIndicator.setColorFilter(U.getAccentColor(this));
+            } else
+                runningAppIndicator.setVisibility(View.GONE);
+        }
+
         return convertView;
     }
 
index b9663a2..a02f3e2 100644 (file)
@@ -1253,6 +1253,7 @@ public class U {
             editor.putBoolean("button_home", true);
             editor.putBoolean("button_recents", true);
             editor.putBoolean("auto_hide_navbar", true);
+            editor.putBoolean("shortcut_icon", false);
             editor.putBoolean("bliss_os_prefs", true);
             editor.apply();
         }
@@ -1269,6 +1270,7 @@ public class U {
                     .putString("window_size", "phone_size")
                     .putBoolean("full_length", true)
                     .putBoolean("dashboard", true)
+                    .putBoolean("shortcut_icon", false)
                     .putBoolean("android_x86_prefs", true)
                     .apply();
         }
diff --git a/app/src/main/res/drawable/running_app_indicator.xml b/app/src/main/res/drawable/running_app_indicator.xml
new file mode 100644 (file)
index 0000000..1c14066
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+    <solid android:color="@android:color/white" />
+    <size
+        android:height="4dp"
+        android:width="4dp"/>
+</shape>
\ No newline at end of file
index 14f6377..9141c53 100644 (file)
         android:scaleX="-1"
         android:visibility="gone"
         tools:visibility="visible" />
+    
+    <ImageView
+        android:id="@+id/running_app_indicator"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom|center"
+        android:layout_marginBottom="2dp"
+        android:src="@drawable/running_app_indicator"
+        android:visibility="gone"
+        tools:visibility="visible"/>
 
 </FrameLayout>