OSDN Git Service

Bugfixes for Bliss OS + implement alternative solution for hiding navbar
authorBraden Farmer <farmerbb@gmail.com>
Sun, 10 Nov 2019 07:39:44 +0000 (00:39 -0700)
committerBraden Farmer <farmerbb@gmail.com>
Sun, 10 Nov 2019 07:39:44 +0000 (00:39 -0700)
app/build.gradle
app/src/androidx86/java/com/farmerbb/taskbar/BuildConfig.java
app/src/main/java/com/farmerbb/taskbar/activity/NavigationBarButtonsActivity.java
app/src/main/java/com/farmerbb/taskbar/ui/TaskbarController.java
app/src/main/java/com/farmerbb/taskbar/util/CommandDispatcher.java [new file with mode: 0644]
app/src/main/java/com/farmerbb/taskbar/util/U.java
app/src/main/res/values/integers.xml
lib/build.gradle

index d4ae501..b75f53d 100644 (file)
@@ -24,6 +24,7 @@ android {
         buildConfigField "String", "PAID_APPLICATION_ID", "\"com.farmerbb.taskbar.paid\""
         buildConfigField "String", "SUPPORT_APPLICATION_ID", "\"com.farmerbb.taskbar.support\""
         buildConfigField "String", "ANDROIDX86_APPLICATION_ID", "\"com.farmerbb.taskbar.androidx86\""
+        buildConfigField "String", "SS_SUPPORT_APPLICATION_ID", "\"com.farmerbb.secondscreen.support\""
     }
 
     compileOptions {
index c9beee5..cb8c01f 100644 (file)
@@ -10,5 +10,6 @@ public final class BuildConfig {
   public static final String ANDROIDX86_APPLICATION_ID = "com.farmerbb.taskbar.androidx86";
   public static final String BASE_APPLICATION_ID = "com.farmerbb.taskbar";
   public static final String PAID_APPLICATION_ID = "com.farmerbb.taskbar.paid";
+  public static final String SS_SUPPORT_APPLICATION_ID = "com.farmerbb.secondscreen.support";
   public static final String SUPPORT_APPLICATION_ID = "com.farmerbb.taskbar.support";
 }
index 466daf6..e3270cf 100644 (file)
@@ -38,7 +38,7 @@ public class NavigationBarButtonsActivity extends PreferenceActivity implements
         findPreference("button_home").setOnPreferenceClickListener(this);
         findPreference("button_recents").setOnPreferenceClickListener(this);
 
-        if(U.isBlissOs(this))
+        if(U.isBlissOs(this) || U.hasSecondScreenSupportLibrary(this))
             findPreference("auto_hide_navbar").setOnPreferenceClickListener(this);
         else
             getPreferenceScreen().removePreference(findPreference("auto_hide_navbar_category"));
index 778c1ee..1e781fe 100644 (file)
@@ -929,7 +929,7 @@ public class TaskbarController implements UIController {
                 }
 
                 if(!shouldRedrawTaskbar && runningAppsOnly) {
-                    for(int i = 0; i < finalApplicationIds.size(); i++) {
+                    for(int i = 0; i < currentRunningAppIds.size(); i++) {
                         if(!currentRunningAppIds.get(i).equals(prevRunningAppIds.get(i))) {
                             shouldRedrawTaskbar = true;
                             break;
diff --git a/app/src/main/java/com/farmerbb/taskbar/util/CommandDispatcher.java b/app/src/main/java/com/farmerbb/taskbar/util/CommandDispatcher.java
new file mode 100644 (file)
index 0000000..23765eb
--- /dev/null
@@ -0,0 +1,62 @@
+/* Copyright 2019 Braden Farmer
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.farmerbb.taskbar.util;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.farmerbb.taskbar.BuildConfig;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommandDispatcher {
+
+    private List<String> commands = new ArrayList<>();
+
+    private static CommandDispatcher theInstance;
+
+    private CommandDispatcher() {}
+
+    public static CommandDispatcher getInstance() {
+        if(theInstance == null) theInstance = new CommandDispatcher();
+
+        return theInstance;
+    }
+
+    boolean addCommand(Context context, String command) {
+        if(U.hasSecondScreenSupportLibrary(context) && !command.isEmpty()) {
+            commands.add(command);
+            return true;
+        }
+
+        return false;
+    }
+
+    void dispatch(Context context) {
+        if(U.hasSecondScreenSupportLibrary(context)) {
+            Intent intent = new Intent(BuildConfig.SS_SUPPORT_APPLICATION_ID + ".DISPATCH_COMMANDS");
+            intent.setPackage(BuildConfig.SS_SUPPORT_APPLICATION_ID);
+
+            if(!commands.isEmpty())
+                intent.putExtra("commands", commands.toArray(new String[commands.size()]));
+
+            context.sendBroadcast(intent);
+        }
+
+        theInstance = null;
+    }
+}
\ No newline at end of file
index 8431149..c90b6f6 100644 (file)
@@ -1187,6 +1187,17 @@ public class U {
     }
 
     public static void showHideNavigationBar(Context context, boolean show) {
+        if(hasSecondScreenSupportLibrary(context)) {
+            CommandDispatcher dispatcher = CommandDispatcher.getInstance();
+            int value = show ? 0 : getNavbarHeight(context) * -1;
+            String command = "wm overscan 0,0,0," + value + " -d " + getDisplayID();
+
+            if(dispatcher.addCommand(context, command)) {
+                dispatcher.dispatch(context);
+                return;
+            }
+        }
+
         // Show or hide the system navigation bar on Bliss-x86
         try {
             if(getCurrentApiVersion() >= 28.0f)
@@ -1241,8 +1252,8 @@ public class U {
             editor.putBoolean("button_back", true);
             editor.putBoolean("button_home", true);
             editor.putBoolean("button_recents", true);
-         // editor.putBoolean("auto_hide_navbar", true);
-         // editor.putBoolean("shortcut_icon", false);
+            editor.putBoolean("auto_hide_navbar", true);
+            editor.putBoolean("shortcut_icon", false);
             editor.putBoolean("bliss_os_prefs", true);
             editor.apply();
         }
@@ -1268,14 +1279,7 @@ public class U {
 
     public static DisplayInfo getDisplayInfo(Context context, boolean fromTaskbar) {
         context = context.getApplicationContext();
-
-        LauncherHelper helper = LauncherHelper.getInstance();
-        int displayID;
-
-        if(helper.isOnSecondaryHomeScreen())
-            displayID = helper.getSecondaryDisplayId();
-        else
-            displayID = Display.DEFAULT_DISPLAY;
+        int displayID = getDisplayID();
 
         DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
         Display currentDisplay = null;
@@ -1328,6 +1332,15 @@ public class U {
         return info;
     }
 
+    private static int getDisplayID() {
+        LauncherHelper helper = LauncherHelper.getInstance();
+
+        if(helper.isOnSecondaryHomeScreen())
+            return helper.getSecondaryDisplayId();
+        else
+            return Display.DEFAULT_DISPLAY;
+    }
+
     public static void pinAppShortcut(Context context) {
         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
             ShortcutManager mShortcutManager = context.getSystemService(ShortcutManager.class);
@@ -1632,4 +1645,15 @@ public class U {
 
         return false;
     }
+
+    public static boolean hasSecondScreenSupportLibrary(Context context) {
+        PackageManager pm = context.getPackageManager();
+        try {
+            pm.getPackageInfo(BuildConfig.SS_SUPPORT_APPLICATION_ID, 0);
+            return pm.checkSignatures(BuildConfig.SS_SUPPORT_APPLICATION_ID, context.getPackageName())
+                    == PackageManager.SIGNATURE_MATCH;
+        } catch (PackageManager.NameNotFoundException e) {
+            return false;
+        }
+    }
 }
index d29b4be..9010dd0 100644 (file)
@@ -15,7 +15,7 @@
 -->
 
 <resources>
-    <integer name="tb_translucent_gray">0x60000000</integer>
+    <integer name="tb_translucent_gray">0x66000000</integer>
     <integer name="tb_translucent_white">0xFFF0F0F0</integer>
     <integer name="tb_dashboard_width">2</integer>
     <integer name="tb_dashboard_height">2</integer>
index f2435ab..11d21b3 100644 (file)
@@ -29,6 +29,7 @@ android {
         buildConfigField "String", "PAID_APPLICATION_ID", "\"com.farmerbb.taskbar.paid\""
         buildConfigField "String", "SUPPORT_APPLICATION_ID", "\"com.farmerbb.taskbar.support\""
         buildConfigField "String", "ANDROIDX86_APPLICATION_ID", "\"com.farmerbb.taskbar.androidx86\""
+        buildConfigField "String", "SS_SUPPORT_APPLICATION_ID", "\"com.farmerbb.secondscreen.support\""
     }
 
     compileOptions {