From a5f112f461b8850cfb5185fb1261071ed69642a6 Mon Sep 17 00:00:00 2001 From: weathon Date: Thu, 18 Jul 2019 08:36:56 +0200 Subject: [PATCH] Added the ability to exclude packages from the launcher by adding them to the 'excludedpackages.txt' in the android/data/aaa.QuestAppLauncher.App/files folder; --- Assets/Scripts/GridPopulation.cs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/GridPopulation.cs b/Assets/Scripts/GridPopulation.cs index 2d26987..878e575 100644 --- a/Assets/Scripts/GridPopulation.cs +++ b/Assets/Scripts/GridPopulation.cs @@ -18,6 +18,9 @@ namespace QuestAppLauncher // File name of app name overrides const string AppNameOverrideFile = "appnames.txt"; + // File name of excluded package names + const string ExcludedPackagesFile = "excludedpackages.txt"; + // Extension search for icon overrides const string IconOverrideExtSearch = "*.jpg"; @@ -96,13 +99,29 @@ namespace QuestAppLauncher { // Dictionary to hold package name -> app index, app name var packageNameToAppName = new Dictionary(); + var excludedPackageNames = new HashSet(); // Get # of installed apps int numApps = currentActivity.Call("getSize"); Debug.Log("# installed apps: " + numApps); - // Get current package name (to filter this out)) - var currentPackageName = currentActivity.Call("getPackageName"); + // Add current package name to excludedPackageNames to filter it out + excludedPackageNames.Add(currentActivity.Call("getPackageName")); + + //This is a file containing packageNames that will be excluded + var excludedPackageNamesFilePath = Path.Combine(persistentDataPath, ExcludedPackagesFile); + if (File.Exists(excludedPackageNamesFilePath)) + { + Debug.Log("Found file: " + excludedPackageNamesFilePath); + string[] excludedPackages = File.ReadAllLines(excludedPackageNamesFilePath); + foreach (string excludedPackage in excludedPackages) + { + if (!string.IsNullOrEmpty(excludedPackage)) + { + excludedPackageNames.Add(excludedPackage); + } + } + } // Get installed package and app names for (int i = 0; i < numApps; i++) @@ -110,12 +129,14 @@ namespace QuestAppLauncher var packageName = currentActivity.Call("getPackageName", i); var appName = currentActivity.Call("getAppName", i); - if (packageName.Equals(currentPackageName)) + if (excludedPackageNames.Contains(packageName)) { - // Skip current package + Debug.Log("Skipping [" + i + "] package: " + packageName + ", name: " + appName); + // Skip exluded package continue; } + packageNameToAppName.Add(packageName, (i, appName)); Debug.Log("[" + i + "] package: " + packageName + ", name: " + appName); }